diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs index 9ca9276138fe..9ae3647578ff 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Threading; using Azure.Core; using Azure.Core.Pipeline; @@ -15,13 +16,10 @@ namespace Azure.AI.Projects /// The AIProject service client. public partial class AIProjectClient { - private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com/.default" }; + private static readonly string[] AuthorizationScopes = new string[] { "https://ai.azure.com/.default" }; private readonly TokenCredential _tokenCredential; private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; - private readonly string _subscriptionId; - private readonly string _resourceGroupName; - private readonly string _projectName; /// The ClientDiagnostics is used to provide tracing support for the client library. internal ClientDiagnostics ClientDiagnostics { get; } @@ -30,55 +28,106 @@ public partial class AIProjectClient public virtual HttpPipeline Pipeline => _pipeline; /// Initializes a new instance of AIProjectClient. - /// The Azure AI Foundry project endpoint, in the form `https://<azure-region>.api.azureml.ms` or `https://<private-link-guid>.<azure-region>.api.azureml.ms`, where <azure-region> is the Azure region where the project is deployed (e.g. westus) and <private-link-guid> is the GUID of the Enterprise private link. - /// The Azure subscription ID. - /// The name of the Azure Resource Group. - /// The Azure AI Foundry project name. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// /// A credential used to authenticate to an Azure Service. - /// , , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public AIProjectClient(Uri endpoint, string subscriptionId, string resourceGroupName, string projectName, TokenCredential credential) : this(endpoint, subscriptionId, resourceGroupName, projectName, credential, new AIProjectClientOptions()) + /// or is null. + public AIProjectClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AIProjectClientOptions()) { } - /// Initializes a new instance of AgentsClient. + /// Initializes a new instance of AIProjectClient. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AIProjectClient(Uri endpoint, TokenCredential credential, AIProjectClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AIProjectClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + private ServicePatterns _cachedServicePatterns; + + /// Initializes a new instance of ServicePatterns. + public virtual ServicePatterns GetServicePatternsClient() + { + return Volatile.Read(ref _cachedServicePatterns) ?? Interlocked.CompareExchange(ref _cachedServicePatterns, new ServicePatterns(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint), null) ?? _cachedServicePatterns; + } + + /// Initializes a new instance of ConnectionsClient. /// The API version to use for this operation. /// is null. - public virtual AgentsClient GetAgentsClient(string apiVersion = "2024-07-01-preview") + public virtual ConnectionsClient GetConnectionsClient(string apiVersion = "2025-05-15-preview") { Argument.AssertNotNull(apiVersion, nameof(apiVersion)); - return new AgentsClient(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _subscriptionId, _resourceGroupName, _projectName, apiVersion); + return new ConnectionsClient(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); } - /// Initializes a new instance of ConnectionsClient. + /// Initializes a new instance of EvaluationsClient. /// The API version to use for this operation. /// is null. - public virtual ConnectionsClient GetConnectionsClient(string apiVersion = "2024-07-01-preview") + public virtual EvaluationsClient GetEvaluationsClient(string apiVersion = "2025-05-15-preview") { Argument.AssertNotNull(apiVersion, nameof(apiVersion)); - return new ConnectionsClient(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _subscriptionId, _resourceGroupName, _projectName, apiVersion); + return new EvaluationsClient(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); } - /// Initializes a new instance of TelemetryClient. + /// Initializes a new instance of Datasets. /// The API version to use for this operation. /// is null. - public virtual TelemetryClient GetTelemetryClient(string apiVersion = "2024-07-01-preview") + public virtual Datasets GetDatasetsClient(string apiVersion = "2025-05-15-preview") { Argument.AssertNotNull(apiVersion, nameof(apiVersion)); - return new TelemetryClient(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _subscriptionId, _resourceGroupName, _projectName, apiVersion); + return new Datasets(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); } - /// Initializes a new instance of EvaluationsClient. + /// Initializes a new instance of Indexes. + /// The API version to use for this operation. + /// is null. + public virtual Indexes GetIndexesClient(string apiVersion = "2025-05-15-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Indexes(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Deployments. + /// The API version to use for this operation. + /// is null. + public virtual Deployments GetDeploymentsClient(string apiVersion = "2025-05-15-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Deployments(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of RedTeams. /// The API version to use for this operation. /// is null. - public virtual EvaluationsClient GetEvaluationsClient(string apiVersion = "2024-07-01-preview") + public virtual RedTeams GetRedTeamsClient(string apiVersion = "2025-05-15-preview") { Argument.AssertNotNull(apiVersion, nameof(apiVersion)); - return new EvaluationsClient(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _subscriptionId, _resourceGroupName, _projectName, apiVersion); + return new RedTeams(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs index ee91a3c1030c..bd7e9bf96efb 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs @@ -13,13 +13,15 @@ namespace Azure.AI.Projects /// Client options for AIProjectClient. public partial class AIProjectClientOptions : ClientOptions { - private const ServiceVersion LatestVersion = ServiceVersion.V2024_07_01_Preview; + private const ServiceVersion LatestVersion = ServiceVersion.V2025_05_15_Preview; /// The version of the service to use. public enum ServiceVersion { - /// Service version "2024-07-01-preview". - V2024_07_01_Preview = 1, + /// Service version "2025-05-01". + V2025_05_01 = 1, + /// Service version "2025-05-15-preview". + V2025_05_15_Preview = 2, } internal string Version { get; } @@ -29,7 +31,8 @@ public AIProjectClientOptions(ServiceVersion version = LatestVersion) { Version = version switch { - ServiceVersion.V2024_07_01_Preview => "2024-07-01-preview", + ServiceVersion.V2025_05_01 => "2025-05-01", + ServiceVersion.V2025_05_15_Preview => "2025-05-15-preview", _ => throw new NotSupportedException() }; } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsClientBuilderExtensions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsClientBuilderExtensions.cs index acd83ee1a217..4e1d42a02a2f 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsClientBuilderExtensions.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsClientBuilderExtensions.cs @@ -16,14 +16,16 @@ public static partial class AIProjectsClientBuilderExtensions { /// Registers a instance. /// The builder to register with. - /// The Azure AI Foundry project endpoint, in the form `https://<azure-region>.api.azureml.ms` or `https://<private-link-guid>.<azure-region>.api.azureml.ms`, where <azure-region> is the Azure region where the project is deployed (e.g. westus) and <private-link-guid> is the GUID of the Enterprise private link. - /// The Azure subscription ID. - /// The name of the Azure Resource Group. - /// The Azure AI Foundry project name. - public static IAzureClientBuilder AddAIProjectClient(this TBuilder builder, Uri endpoint, string subscriptionId, string resourceGroupName, string projectName) + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// + public static IAzureClientBuilder AddAIProjectClient(this TBuilder builder, Uri endpoint) where TBuilder : IAzureClientFactoryBuilderWithCredential { - return builder.RegisterClientFactory((options, cred) => new AIProjectClient(endpoint, subscriptionId, resourceGroupName, projectName, cred, options)); + return builder.RegisterClientFactory((options, cred) => new AIProjectClient(endpoint, cred, options)); } /// Registers a instance. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs index 8d636f59179e..c14834a5d317 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs @@ -14,661 +14,85 @@ namespace Azure.AI.Projects /// Model factory for models. public static partial class AIProjectsModelFactory { - /// Initializes a new instance of . - /// The type of binding, which is always 'storage_queue'. - /// Storage queue. - /// A new instance for mocking. - public static AzureFunctionBinding AzureFunctionBinding(AzureFunctionBindingType type = default, AzureFunctionStorageQueue storageQueue = null) - { - return new AzureFunctionBinding(type, storageQueue, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Type. - /// The JSON schema, describing response format. - /// A new instance for mocking. - public static ResponseFormatJsonSchemaType ResponseFormatJsonSchemaType(ResponseFormatJsonSchemaTypeType type = default, ResponseFormatJsonSchema jsonSchema = null) - { - return new ResponseFormatJsonSchemaType(type, jsonSchema, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// - /// The role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). + /// Initializes a new instance of . + /// The friendly name of the connection, provided by the user. + /// A unique identifier for the connection, generated by the service. + /// Category of the connection. + /// The connection URL to be used for this service. + /// Whether the connection is tagged as the default connection of its type. + /// + /// The credentials used by the connection + /// 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 . /// - /// A list of files attached to the message, and the tools they should be added to. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// A new instance for mocking. - public static ThreadMessageOptions ThreadMessageOptions(MessageRole role = default, BinaryData content = null, IEnumerable attachments = null, IDictionary metadata = null) + /// Metadata of the connection. + /// A new instance for mocking. + public static Connection Connection(string name = null, string id = null, ConnectionType type = default, string target = null, bool isDefault = default, BaseCredentials credentials = null, IReadOnlyDictionary metadata = null) { - attachments ??= new List(); metadata ??= new Dictionary(); - return new ThreadMessageOptions(role, content, attachments?.ToList(), metadata, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The plain text content for this block. - /// A new instance for mocking. - public static MessageInputTextBlock MessageInputTextBlock(string text = null) - { - return new MessageInputTextBlock(MessageBlockType.Text, serializedAdditionalRawData: null, text); - } - - /// Initializes a new instance of . - /// Information about the referenced image file, including file ID and optional detail level. - /// A new instance for mocking. - public static MessageInputImageFileBlock MessageInputImageFileBlock(MessageImageFileParam imageFile = null) - { - return new MessageInputImageFileBlock(MessageBlockType.ImageFile, serializedAdditionalRawData: null, imageFile); - } - - /// Initializes a new instance of . - /// The ID of the previously uploaded image file. - /// Optional detail level for the image (auto, low, or high). - /// A new instance for mocking. - public static MessageImageFileParam MessageImageFileParam(string fileId = null, ImageDetailLevel? detail = null) - { - return new MessageImageFileParam(fileId, detail, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Information about the external image URL, including the URL and optional detail level. - /// A new instance for mocking. - public static MessageInputImageUrlBlock MessageInputImageUrlBlock(MessageImageUrlParam imageUrl = null) - { - return new MessageInputImageUrlBlock(MessageBlockType.ImageUrl, serializedAdditionalRawData: null, imageUrl); - } - - /// Initializes a new instance of . - /// The publicly accessible URL of the external image. - /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. - /// A new instance for mocking. - public static MessageImageUrlParam MessageImageUrlParam(string url = null, ImageDetailLevel? detail = null) - { - return new MessageImageUrlParam(url, detail, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The provided reason describing why the message was marked as incomplete. - /// A new instance for mocking. - public static MessageIncompleteDetails MessageIncompleteDetails(MessageIncompleteDetailsReason reason = default) - { - return new MessageIncompleteDetails(reason, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The object type. - /// The textual content associated with this text annotation item. - /// A new instance for mocking. - public static MessageTextAnnotation MessageTextAnnotation(string type = null, string text = null) - { - return new UnknownMessageTextAnnotation(type, text, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The textual content associated with this text annotation item. - /// The details of the URL citation. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. - /// A new instance for mocking. - public static MessageTextUrlCitationAnnotation MessageTextUrlCitationAnnotation(string text = null, MessageTextUrlCitationDetails urlCitation = null, int? startIndex = null, int? endIndex = null) - { - return new MessageTextUrlCitationAnnotation( - "url_citation", - text, - serializedAdditionalRawData: null, - urlCitation, - startIndex, - endIndex); - } - - /// Initializes a new instance of . - /// The URL associated with this citation. - /// The title of the URL. - /// A new instance for mocking. - public static MessageTextUrlCitationDetails MessageTextUrlCitationDetails(string url = null, string title = null) - { - return new MessageTextUrlCitationDetails(url, title, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The object type. - /// The ID of the tool call. This ID must be referenced when submitting tool outputs. - /// A new instance for mocking. - public static RequiredToolCall RequiredToolCall(string type = null, string id = null) - { - return new UnknownRequiredToolCall(type, serializedAdditionalRawData: null, id); - } - - /// Initializes a new instance of . - /// The status for the error. - /// The human-readable text associated with the error. - /// A new instance for mocking. - public static RunError RunError(string code = null, string message = null) - { - return new RunError(code, message, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The reason why the run is incomplete. This indicates which specific token limit was reached during the run. - /// A new instance for mocking. - public static IncompleteRunDetails IncompleteRunDetails(IncompleteDetailsReason reason = default) - { - return new IncompleteRunDetails(reason, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Number of completion tokens used over the course of the run. - /// Number of prompt tokens used over the course of the run. - /// Total number of tokens used (prompt + completion). - /// A new instance for mocking. - public static RunCompletionUsage RunCompletionUsage(long completionTokens = default, long promptTokens = default, long totalTokens = default) - { - return new RunCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Information about the message creation associated with this run step. - /// A new instance for mocking. - public static RunStepMessageCreationDetails RunStepMessageCreationDetails(RunStepMessageCreationReference messageCreation = null) - { - return new RunStepMessageCreationDetails(RunStepType.MessageCreation, serializedAdditionalRawData: null, messageCreation); - } - - /// Initializes a new instance of . - /// The ID of the message created by this run step. - /// A new instance for mocking. - public static RunStepMessageCreationReference RunStepMessageCreationReference(string messageId = null) - { - return new RunStepMessageCreationReference(messageId, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// - /// 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 . - /// - /// A new instance for mocking. - public static RunStepToolCallDetails RunStepToolCallDetails(IEnumerable toolCalls = null) - { - toolCalls ??= new List(); - - return new RunStepToolCallDetails(RunStepType.ToolCalls, serializedAdditionalRawData: null, toolCalls?.ToList()); - } - - /// Initializes a new instance of . - /// The object type. - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// A new instance for mocking. - public static RunStepToolCall RunStepToolCall(string type = null, string id = null) - { - return new UnknownRunStepToolCall(type, id, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The serialized log output emitted by the code interpreter. - /// A new instance for mocking. - public static RunStepCodeInterpreterLogOutput RunStepCodeInterpreterLogOutput(string logs = null) - { - return new RunStepCodeInterpreterLogOutput("logs", serializedAdditionalRawData: null, logs); - } - - /// Initializes a new instance of . - /// Referential information for the image associated with this output. - /// A new instance for mocking. - public static RunStepCodeInterpreterImageOutput RunStepCodeInterpreterImageOutput(RunStepCodeInterpreterImageReference image = null) - { - return new RunStepCodeInterpreterImageOutput("image", serializedAdditionalRawData: null, image); - } - - /// Initializes a new instance of . - /// The ID of the file associated with this image. - /// A new instance for mocking. - public static RunStepCodeInterpreterImageReference RunStepCodeInterpreterImageReference(string fileId = null) - { - return new RunStepCodeInterpreterImageReference(fileId, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// For now, this is always going to be an empty object. - /// A new instance for mocking. - public static RunStepFileSearchToolCall RunStepFileSearchToolCall(string id = null, RunStepFileSearchToolCallResults fileSearch = null) - { - return new RunStepFileSearchToolCall("file_search", id, serializedAdditionalRawData: null, fileSearch); - } - - /// Initializes a new instance of . - /// Ranking options for file search. - /// The array of a file search results. - /// A new instance for mocking. - public static RunStepFileSearchToolCallResults RunStepFileSearchToolCallResults(FileSearchRankingOptions rankingOptions = null, IEnumerable results = null) - { - results ??= new List(); - - return new RunStepFileSearchToolCallResults(rankingOptions, results?.ToList(), serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The ID of the file that result was found in. - /// The name of the file that result was found in. - /// The score of the result. All values must be a floating point number between 0 and 1. - /// The content of the result that was found. The content is only included if requested via the include query parameter. - /// A new instance for mocking. - public static RunStepFileSearchToolCallResult RunStepFileSearchToolCallResult(string fileId = null, string fileName = null, float score = default, IEnumerable content = null) - { - content ??= new List(); - - return new RunStepFileSearchToolCallResult(fileId, fileName, score, content?.ToList(), serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The type of the content. - /// The text content of the file. - /// A new instance for mocking. - public static FileSearchToolCallContent FileSearchToolCallContent(FileSearchToolCallContentType type = default, string text = null) - { - return new FileSearchToolCallContent(type, text, serializedAdditionalRawData: null); - } - - /// 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 RunStepBingGroundingToolCall RunStepBingGroundingToolCall(string id = null, IReadOnlyDictionary bingGrounding = null) - { - bingGrounding ??= new Dictionary(); - - return new RunStepBingGroundingToolCall("bing_grounding", id, serializedAdditionalRawData: null, bingGrounding); - } - - /// 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 RunStepAzureAISearchToolCall RunStepAzureAISearchToolCall(string id = null, IReadOnlyDictionary azureAISearch = null) - { - azureAISearch ??= new Dictionary(); - - return new RunStepAzureAISearchToolCall("azure_ai_search", id, serializedAdditionalRawData: null, azureAISearch); - } - - /// 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 RunStepSharepointToolCall RunStepSharepointToolCall(string id = null, IReadOnlyDictionary sharePoint = null) - { - sharePoint ??= new Dictionary(); - - return new RunStepSharepointToolCall("sharepoint_grounding", id, serializedAdditionalRawData: null, sharePoint); - } - - /// 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 RunStepMicrosoftFabricToolCall RunStepMicrosoftFabricToolCall(string id = null, IReadOnlyDictionary microsoftFabric = null) - { - microsoftFabric ??= new Dictionary(); - - 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. - /// A new instance for mocking. - public static RunStepError RunStepError(RunStepErrorCode code = default, string message = null) - { - return new RunStepError(code, message, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Number of completion tokens used over the course of the run step. - /// Number of prompt tokens used over the course of the run step. - /// Total number of tokens used (prompt + completion). - /// A new instance for mocking. - public static RunStepCompletionUsage RunStepCompletionUsage(long completionTokens = default, long promptTokens = default, long totalTokens = default) - { - return new RunStepCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// A new instance for mocking. - public static AgentPageableListOfVectorStore AgentPageableListOfVectorStore(AgentPageableListOfVectorStoreObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default) - { - data ??= new List(); - - return new AgentPageableListOfVectorStore( - @object, - data?.ToList(), - firstId, - lastId, - hasMore, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always `vector_store`. - /// The Unix timestamp (in seconds) for when the vector store was created. - /// The name of the vector store. - /// The total number of bytes used by the files in the vector store. - /// Files count grouped by status processed or being processed by this vector store. - /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. - /// Details on when this vector store expires. - /// The Unix timestamp (in seconds) for when the vector store will expire. - /// The Unix timestamp (in seconds) for when the vector store was last active. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// A new instance for mocking. - public static VectorStore VectorStore(string id = null, VectorStoreObject @object = default, DateTimeOffset createdAt = default, string name = null, int usageBytes = default, VectorStoreFileCount fileCounts = null, VectorStoreStatus status = default, VectorStoreExpirationPolicy expiresAfter = null, DateTimeOffset? expiresAt = null, DateTimeOffset? lastActiveAt = null, IReadOnlyDictionary metadata = null) - { - metadata ??= new Dictionary(); - - return new VectorStore( - id, - @object, - createdAt, + return new Connection( name, - usageBytes, - fileCounts, - status, - expiresAfter, - expiresAt, - lastActiveAt, - metadata, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The number of files that are currently being processed. - /// The number of files that have been successfully processed. - /// The number of files that have failed to process. - /// The number of files that were cancelled. - /// The total number of files. - /// A new instance for mocking. - public static VectorStoreFileCount VectorStoreFileCount(int inProgress = default, int completed = default, int failed = default, int cancelled = default, int total = default) - { - return new VectorStoreFileCount( - inProgress, - completed, - failed, - cancelled, - total, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The options for the static chunking strategy. - /// A new instance for mocking. - public static VectorStoreStaticChunkingStrategyRequest VectorStoreStaticChunkingStrategyRequest(VectorStoreStaticChunkingStrategyOptions @static = null) - { - return new VectorStoreStaticChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType.Static, serializedAdditionalRawData: null, @static); - } - - /// Initializes a new instance of . - /// The ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// The object type, which is always 'vector_store.deleted'. - /// A new instance for mocking. - public static VectorStoreDeletionStatus VectorStoreDeletionStatus(string id = null, bool deleted = default, VectorStoreDeletionStatusObject @object = default) - { - return new VectorStoreDeletionStatus(id, deleted, @object, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// A new instance for mocking. - public static AgentPageableListOfVectorStoreFile AgentPageableListOfVectorStoreFile(AgentPageableListOfVectorStoreFileObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default) - { - data ??= new List(); - - return new AgentPageableListOfVectorStoreFile( - @object, - data?.ToList(), - firstId, - lastId, - hasMore, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always `vector_store.file`. - /// - /// The total vector store usage in bytes. Note that this may be different from the original file - /// size. - /// - /// The Unix timestamp (in seconds) for when the vector store file was created. - /// The ID of the vector store that the file is attached to. - /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. - /// The last error associated with this vector store file. Will be `null` if there are no errors. - /// - /// The strategy used to chunk the file. - /// 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 . - /// - /// A new instance for mocking. - public static VectorStoreFile VectorStoreFile(string id = null, VectorStoreFileObject @object = default, int usageBytes = default, DateTimeOffset createdAt = default, string vectorStoreId = null, VectorStoreFileStatus status = default, VectorStoreFileError lastError = null, VectorStoreChunkingStrategyResponse chunkingStrategy = null) - { - return new VectorStoreFile( id, - @object, - usageBytes, - createdAt, - vectorStoreId, - status, - lastError, - chunkingStrategy, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// One of `server_error` or `rate_limit_exceeded`. - /// A human-readable description of the error. - /// A new instance for mocking. - public static VectorStoreFileError VectorStoreFileError(VectorStoreFileErrorCode code = default, string message = null) - { - return new VectorStoreFileError(code, message, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The options for the static chunking strategy. - /// A new instance for mocking. - public static VectorStoreStaticChunkingStrategyResponse VectorStoreStaticChunkingStrategyResponse(VectorStoreStaticChunkingStrategyOptions @static = null) - { - return new VectorStoreStaticChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType.Static, serializedAdditionalRawData: null, @static); - } - - /// Initializes a new instance of . - /// The ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// The object type, which is always 'vector_store.deleted'. - /// A new instance for mocking. - public static VectorStoreFileDeletionStatus VectorStoreFileDeletionStatus(string id = null, bool deleted = default, VectorStoreFileDeletionStatusObject @object = default) - { - return new VectorStoreFileDeletionStatus(id, deleted, @object, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always `vector_store.file_batch`. - /// The Unix timestamp (in seconds) for when the vector store files batch was created. - /// The ID of the vector store that the file is attached to. - /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. - /// Files count grouped by status processed or being processed by this vector store. - /// A new instance for mocking. - public static VectorStoreFileBatch VectorStoreFileBatch(string id = null, VectorStoreFileBatchObject @object = default, DateTimeOffset createdAt = default, string vectorStoreId = null, VectorStoreFileBatchStatus status = default, VectorStoreFileCount fileCounts = null) - { - return new VectorStoreFileBatch( - id, - @object, - createdAt, - vectorStoreId, - status, - fileCounts, + type, + target, + isDefault, + credentials, + metadata, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// A unique identifier for the resource. - /// The name of the resource. - /// The properties of the resource. - /// A new instance for mocking. - public static GetWorkspaceResponse GetWorkspaceResponse(string id = null, string name = null, WorkspaceProperties properties = null) - { - return new GetWorkspaceResponse(id, name, properties, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// A new instance for mocking. - public static WorkspaceProperties WorkspaceProperties(string applicationInsights = null) + /// Initializes a new instance of . + /// API Key. + /// A new instance for mocking. + public static ApiKeyCredentials ApiKeyCredentials(string apiKey = null) { - return new WorkspaceProperties(applicationInsights, serializedAdditionalRawData: null); + return new ApiKeyCredentials(CredentialType.ApiKey, serializedAdditionalRawData: null, apiKey); } - /// Initializes a new instance of . - /// A list of connection list secrets. - /// A new instance for mocking. - public static ListConnectionsResponse ListConnectionsResponse(IEnumerable value = null) + /// Initializes a new instance of . + /// The credential type. + /// A new instance for mocking. + public static CustomCredential CustomCredential(IReadOnlyDictionary keys = null) { - value ??= new List(); + keys ??= new Dictionary(); - return new ListConnectionsResponse(value?.ToList(), serializedAdditionalRawData: null); + return new CustomCredential(CredentialType.Custom, serializedAdditionalRawData: null, keys); } - /// Initializes a new instance of . - /// A unique identifier for the connection. - /// The name of the resource. - /// - /// The properties of the resource - /// 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 . - /// - /// A new instance for mocking. - public static ConnectionResponse ConnectionResponse(string id = null, string name = null, ConnectionProperties properties = null) + /// Initializes a new instance of . + /// SAS token. + /// A new instance for mocking. + public static SASCredentials SASCredentials(string sasToken = null) { - return new ConnectionResponse(id, name, properties, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// A new instance for mocking. - public static ConnectionProperties ConnectionProperties(ConnectionType category = default, string target = null) - { - return new UnknownInternalConnectionProperties(default, category, target, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// Credentials will only be present for authType=ApiKey. - /// A new instance for mocking. - public static ConnectionPropertiesApiKeyAuth ConnectionPropertiesApiKeyAuth(ConnectionType category = default, string target = null, CredentialsApiKeyAuth credentials = null) - { - return new ConnectionPropertiesApiKeyAuth(AuthenticationType.ApiKey, category, target, serializedAdditionalRawData: null, credentials); - } - - /// Initializes a new instance of . - /// The API key. - /// A new instance for mocking. - public static CredentialsApiKeyAuth CredentialsApiKeyAuth(string key = null) - { - return new CredentialsApiKeyAuth(key, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// A new instance for mocking. - public static InternalConnectionPropertiesCustomAuth InternalConnectionPropertiesCustomAuth(ConnectionType category = default, string target = null) - { - return new InternalConnectionPropertiesCustomAuth(AuthenticationType.Custom, category, target, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// A new instance for mocking. - public static InternalConnectionPropertiesNoAuth InternalConnectionPropertiesNoAuth(ConnectionType category = default, string target = null) - { - return new InternalConnectionPropertiesNoAuth(AuthenticationType.None, category, target, serializedAdditionalRawData: null); + return new SASCredentials(CredentialType.SAS, serializedAdditionalRawData: null, sasToken); } /// Initializes a new instance of . - /// Identifier of the evaluation. + /// Identifier of the evaluation. /// /// Data for evaluation. /// 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 . /// - /// Evaluation target specifying the model config and parameters. /// Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. - /// Metadata containing createdBy and modifiedBy information. /// Status of the evaluation. It is set by service and is read-only. /// Evaluation's tags. Unlike properties, tags are fully mutable. /// Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. /// Evaluators to be used for the evaluation. /// A new instance for mocking. - public static Evaluation Evaluation(string id = null, InputData data = null, EvaluationTarget target = null, string displayName = null, string description = null, SystemData systemData = null, string status = null, IDictionary tags = null, IDictionary properties = null, IDictionary evaluators = null) + public static Evaluation Evaluation(string name = null, InputData data = null, string displayName = null, string description = null, string status = null, IDictionary tags = null, IDictionary properties = null, IDictionary evaluators = null) { tags ??= new Dictionary(); properties ??= new Dictionary(); evaluators ??= new Dictionary(); return new Evaluation( - id, + name, data, - target, displayName, description, - systemData, status, tags, properties, @@ -676,370 +100,393 @@ public static Evaluation Evaluation(string id = null, InputData data = null, Eva serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The timestamp the resource was created at. - /// The identity that created the resource. - /// The identity type that created the resource. - /// The timestamp of resource last modification (UTC). - /// A new instance for mocking. - public static SystemData SystemData(DateTimeOffset? createdAt = null, string createdBy = null, string createdByType = null, DateTimeOffset? lastModifiedAt = null) - { - return new SystemData(createdAt, createdBy, createdByType, lastModifiedAt, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - /// Data for evaluation. - /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. - /// Metadata containing createdBy and modifiedBy information. - /// Provisioning State of the evaluation. It is set by service and is read-only. - /// Evaluation's tags. Unlike properties, tags are fully mutable. - /// Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. - /// Enabled status of the evaluation. It is set by service and is read-only. + /// Initializes a new instance of . + /// Identifier of the agent run. + /// Identifier of the agent thread. This field is mandatory currently, but it will be optional in the future. /// Evaluators to be used for the evaluation. - /// - /// Trigger for the evaluation. - /// 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 . - /// - /// A new instance for mocking. - public static EvaluationSchedule EvaluationSchedule(string name = null, ApplicationInsightsConfiguration data = null, string description = null, SystemData systemData = null, string provisioningState = null, IDictionary tags = null, IDictionary properties = null, string isEnabled = null, IDictionary evaluators = null, Trigger trigger = null) + /// Sampling configuration for the evaluation. + /// Redaction configuration for the evaluation. + /// Pass the AppInsights connection string to the agent evaluation for the evaluation results and the errors logs. + /// A new instance for mocking. + public static AgentEvaluationRequest AgentEvaluationRequest(string runId = null, string threadId = null, IDictionary evaluators = null, AgentEvaluationSamplingConfiguration samplingConfiguration = null, AgentEvaluationRedactionConfiguration redactionConfiguration = null, string appInsightsConnectionString = null) { - tags ??= new Dictionary(); - properties ??= new Dictionary(); evaluators ??= new Dictionary(); - return new EvaluationSchedule( - name, - data, - description, - systemData, - provisioningState, - tags, - properties, - isEnabled, + return new AgentEvaluationRequest( + runId, + threadId, evaluators, - trigger, + samplingConfiguration, + redactionConfiguration, + appInsightsConnectionString, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The identifier of the message, which can be referenced in API endpoints. - /// The object type, which is always `thread.message.delta`. - /// The delta containing the fields that have changed on the Message. - /// A new instance for mocking. - public static MessageDeltaChunk MessageDeltaChunk(string id = null, MessageDeltaChunkObject @object = default, MessageDelta delta = null) - { - return new MessageDeltaChunk(id, @object, delta, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The entity that produced the message. - /// - /// The content of the message as an array of text and/or images. - /// 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 . - /// - /// A new instance for mocking. - public static MessageDelta MessageDelta(MessageRole role = default, IEnumerable content = null) + /// Initializes a new instance of . + /// Identifier of the agent evaluation run. + /// Status of the agent evaluation. Options: Running, Completed, Failed. + /// The reason of the request failure for the long running process, if applicable. + /// The agent evaluation result. + /// A new instance for mocking. + public static AgentEvaluation AgentEvaluation(string id = null, string status = null, string error = null, IEnumerable result = null) { - content ??= new List(); + result ??= new List(); - return new MessageDelta(role, content?.ToList(), serializedAdditionalRawData: null); + return new AgentEvaluation(id, status, error, result?.ToList(), serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The index of the content part of the message. - /// The type of content for this content part. - /// A new instance for mocking. - public static MessageDeltaContent MessageDeltaContent(int index = default, string type = null) + /// Initializes a new instance of . + /// Evaluator's name. This is the name of the evaluator that was used to evaluate the agent's completion. + /// Identifier of the evaluator. + /// Score of the given evaluator. No restriction on range. + /// Status of the evaluator result. Options: Running, Completed, Failed, NotApplicable. + /// Reasoning for the evaluation result. + /// Version of the evaluator that was used to evaluate the agent's completion. + /// The unique identifier of the thread. + /// The unique identifier of the run. + /// A string explaining why there was an error, if applicable. + /// Additional properties relevant to the evaluator. These will differ between evaluators. + /// A new instance for mocking. + public static AgentEvaluationResult AgentEvaluationResult(string evaluator = null, string evaluatorId = null, float score = default, string status = null, string reason = null, string version = null, string threadId = null, string runId = null, string error = null, IReadOnlyDictionary additionalDetails = null) { - return new UnknownMessageDeltaContent(index, type, serializedAdditionalRawData: null); - } + additionalDetails ??= new Dictionary(); - /// Initializes a new instance of . - /// The index of the content part of the message. - /// The image_file data. - /// A new instance for mocking. - public static MessageDeltaImageFileContent MessageDeltaImageFileContent(int index = default, MessageDeltaImageFileContentObject imageFile = null) - { - return new MessageDeltaImageFileContent(index, "image_file", serializedAdditionalRawData: null, imageFile); + return new AgentEvaluationResult( + evaluator, + evaluatorId, + score, + status, + reason, + version, + threadId, + runId, + error, + additionalDetails, + serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The file ID of the image in the message content. - /// A new instance for mocking. - public static MessageDeltaImageFileContentObject MessageDeltaImageFileContentObject(string fileId = null) + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// A new instance for mocking. + public static DatasetVersion DatasetVersion(string dataUri = null, string type = null, bool? isReference = null, string connectionName = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null) { - return new MessageDeltaImageFileContentObject(fileId, serializedAdditionalRawData: null); - } + tags ??= new Dictionary(); - /// Initializes a new instance of . - /// The index of the content part of the message. - /// The text content details. - /// A new instance for mocking. - public static MessageDeltaTextContent MessageDeltaTextContent(int index = default, MessageDeltaTextContentObject text = null) - { - return new MessageDeltaTextContent(index, "text", serializedAdditionalRawData: null, text); + return new UnknownDatasetVersion( + dataUri, + type == null ? default : new DatasetType(type), + isReference, + connectionName, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The data that makes up the text. - /// - /// Annotations for the text. - /// 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 . - /// - /// A new instance for mocking. - public static MessageDeltaTextContentObject MessageDeltaTextContentObject(string value = null, IEnumerable annotations = null) + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// A new instance for mocking. + public static FileDatasetVersion FileDatasetVersion(string dataUri = null, bool? isReference = null, string connectionName = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null) { - annotations ??= new List(); + tags ??= new Dictionary(); - return new MessageDeltaTextContentObject(value, annotations?.ToList(), serializedAdditionalRawData: null); + return new FileDatasetVersion( + dataUri, + DatasetType.UriFile, + isReference, + connectionName, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The type of the text content annotation. - /// A new instance for mocking. - public static MessageDeltaTextAnnotation MessageDeltaTextAnnotation(int index = default, string type = null) + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// A new instance for mocking. + public static FolderDatasetVersion FolderDatasetVersion(string dataUri = null, bool? isReference = null, string connectionName = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null) { - return new UnknownMessageDeltaTextAnnotation(index, type, serializedAdditionalRawData: null); - } + tags ??= new Dictionary(); - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The details of the URL citation. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. - /// A new instance for mocking. - public static MessageDeltaTextUrlCitationAnnotation MessageDeltaTextUrlCitationAnnotation(int index = default, MessageDeltaTextUrlCitationDetails urlCitation = null, int? startIndex = null, int? endIndex = null) - { - return new MessageDeltaTextUrlCitationAnnotation( - index, - "url_citation", - serializedAdditionalRawData: null, - urlCitation, - startIndex, - endIndex); + return new FolderDatasetVersion( + dataUri, + DatasetType.UriFolder, + isReference, + connectionName, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The URL associated with this citation. - /// The title of the URL. - /// A new instance for mocking. - public static MessageDeltaTextUrlCitationDetails MessageDeltaTextUrlCitationDetails(string url = null, string title = null) + /// Initializes a new instance of . + /// If PendingUploadId is not provided, a random GUID will be used. + /// Azure Storage Account connection name to use for generating temporary SAS token. + /// BlobReference is the only supported type. + /// A new instance for mocking. + public static PendingUploadRequest PendingUploadRequest(string pendingUploadId = null, string connectionName = null, PendingUploadType pendingUploadType = default) { - return new MessageDeltaTextUrlCitationDetails(url, title, serializedAdditionalRawData: null); + return new PendingUploadRequest(pendingUploadId, connectionName, pendingUploadType, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The file citation information. - /// The text in the message content that needs to be replaced. - /// The start index of this annotation in the content text. - /// The end index of this annotation in the content text. - /// A new instance for mocking. - public static MessageDeltaTextFileCitationAnnotation MessageDeltaTextFileCitationAnnotation(int index = default, MessageDeltaTextFileCitationAnnotationObject fileCitation = null, string text = null, int? startIndex = null, int? endIndex = null) + /// Initializes a new instance of . + /// Container-level read, write, list SAS. + /// ID for this upload request. + /// Version of asset to be created if user did not specify version when initially creating upload. + /// BlobReference is the only supported type. + /// A new instance for mocking. + public static PendingUploadResponse PendingUploadResponse(BlobReference blobReference = null, string pendingUploadId = null, string version = null, PendingUploadType pendingUploadType = default) { - return new MessageDeltaTextFileCitationAnnotation( - index, - "file_citation", - serializedAdditionalRawData: null, - fileCitation, - text, - startIndex, - endIndex); + return new PendingUploadResponse(blobReference, pendingUploadId, version, pendingUploadType, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The ID of the specific file the citation is from. - /// The specific quote in the cited file. - /// A new instance for mocking. - public static MessageDeltaTextFileCitationAnnotationObject MessageDeltaTextFileCitationAnnotationObject(string fileId = null, string quote = null) + /// Initializes a new instance of . + /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// ARM ID of the storage account to use. + /// Credential info to access the storage account. + /// A new instance for mocking. + public static BlobReference BlobReference(string blobUri = null, string storageAccountArmId = null, SasCredential credential = null) { - return new MessageDeltaTextFileCitationAnnotationObject(fileId, quote, serializedAdditionalRawData: null); + return new BlobReference(blobUri, storageAccountArmId, credential, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The file path information. - /// The start index of this annotation in the content text. - /// The end index of this annotation in the content text. - /// The text in the message content that needs to be replaced. - /// A new instance for mocking. - public static MessageDeltaTextFilePathAnnotation MessageDeltaTextFilePathAnnotation(int index = default, MessageDeltaTextFilePathAnnotationObject filePath = null, int? startIndex = null, int? endIndex = null, string text = null) + /// Initializes a new instance of . + /// SAS uri. + /// Type of credential. + /// A new instance for mocking. + public static SasCredential SasCredential(string sasUri = null, SasCredentialType type = default) { - return new MessageDeltaTextFilePathAnnotation( - index, - "file_path", - serializedAdditionalRawData: null, - filePath, - startIndex, - endIndex, - text); + return new SasCredential(sasUri, type, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The file ID for the annotation. - /// A new instance for mocking. - public static MessageDeltaTextFilePathAnnotationObject MessageDeltaTextFilePathAnnotationObject(string fileId = null) + /// Initializes a new instance of . + /// Credential info to access the storage account. + /// A new instance for mocking. + public static AssetCredentialResponse AssetCredentialResponse(BlobReference blobReference = null) { - return new MessageDeltaTextFilePathAnnotationObject(fileId, serializedAdditionalRawData: null); + return new AssetCredentialResponse(blobReference, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The identifier of the run step, which can be referenced in API endpoints. - /// The object type, which is always `thread.run.step.delta`. - /// The delta containing the fields that have changed on the run step. - /// A new instance for mocking. - public static RunStepDeltaChunk RunStepDeltaChunk(string id = null, RunStepDeltaChunkObject @object = default, RunStepDelta delta = null) + /// Initializes a new instance of . + /// Type of index. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// A new instance for mocking. + public static Index Index(string type = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null) { - return new RunStepDeltaChunk(id, @object, delta, serializedAdditionalRawData: null); - } + tags ??= new Dictionary(); - /// Initializes a new instance of . - /// - /// The details of the 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 . - /// - /// A new instance for mocking. - public static RunStepDelta RunStepDelta(RunStepDeltaDetail stepDetails = null) - { - return new RunStepDelta(stepDetails, serializedAdditionalRawData: null); + return new UnknownIndex( + type == null ? default : new IndexType(type), + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The message creation data. - /// A new instance for mocking. - public static RunStepDeltaMessageCreation RunStepDeltaMessageCreation(RunStepDeltaMessageCreationObject messageCreation = null) + /// Initializes a new instance of . + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Name of connection to Azure AI Search. + /// Name of index in Azure AI Search resource to attach. + /// Field mapping configuration. + /// A new instance for mocking. + public static AzureAISearchIndex AzureAISearchIndex(string id = null, string name = null, string version = null, string description = null, IDictionary tags = null, string connectionName = null, string indexName = null, FieldMapping fieldMapping = null) { - return new RunStepDeltaMessageCreation("message_creation", serializedAdditionalRawData: null, messageCreation); - } + tags ??= new Dictionary(); - /// Initializes a new instance of . - /// The ID of the newly-created message. - /// A new instance for mocking. - public static RunStepDeltaMessageCreationObject RunStepDeltaMessageCreationObject(string messageId = null) - { - return new RunStepDeltaMessageCreationObject(messageId, serializedAdditionalRawData: null); + return new AzureAISearchIndex( + IndexType.AzureSearch, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null, + connectionName, + indexName, + fieldMapping); } - /// Initializes a new instance of . - /// - /// The collection of tool calls for the tool call detail item. - /// 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 . - /// - /// A new instance for mocking. - public static RunStepDeltaToolCallObject RunStepDeltaToolCallObject(IEnumerable toolCalls = null) + /// Initializes a new instance of . + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Vector store id of managed index. + /// A new instance for mocking. + public static ManagedAzureAISearchIndex ManagedAzureAISearchIndex(string id = null, string name = null, string version = null, string description = null, IDictionary tags = null, string vectorStoreId = null) { - toolCalls ??= new List(); + tags ??= new Dictionary(); - return new RunStepDeltaToolCallObject("tool_calls", serializedAdditionalRawData: null, toolCalls?.ToList()); + return new ManagedAzureAISearchIndex( + IndexType.ManagedAzureSearch, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null, + vectorStoreId); } - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// The type of the tool call detail item in a streaming run step's details. - /// A new instance for mocking. - public static RunStepDeltaToolCall RunStepDeltaToolCall(int index = default, string id = null, string type = null) + /// Initializes a new instance of . + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Name of connection to CosmosDB. + /// Name of the CosmosDB Database. + /// Name of CosmosDB Container. + /// Embedding model configuration. + /// Field mapping configuration. + /// A new instance for mocking. + public static CosmosDBIndex CosmosDBIndex(string id = null, string name = null, string version = null, string description = null, IDictionary tags = null, string connectionName = null, string databaseName = null, string containerName = null, EmbeddingConfiguration embeddingConfiguration = null, FieldMapping fieldMapping = null) { - return new UnknownRunStepDeltaToolCall(index, id, type, serializedAdditionalRawData: null); - } + tags ??= new Dictionary(); - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// The function data for the tool call. - /// A new instance for mocking. - public static RunStepDeltaFunctionToolCall RunStepDeltaFunctionToolCall(int index = default, string id = null, RunStepDeltaFunction function = null) - { - return new RunStepDeltaFunctionToolCall(index, id, "function", serializedAdditionalRawData: null, function); + return new CosmosDBIndex( + IndexType.CosmosDB, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null, + connectionName, + databaseName, + containerName, + embeddingConfiguration, + fieldMapping); } - /// Initializes a new instance of . - /// The name of the function. - /// The arguments passed to the function as input. - /// The output of the function, null if outputs have not yet been submitted. - /// A new instance for mocking. - public static RunStepDeltaFunction RunStepDeltaFunction(string name = null, string arguments = null, string output = null) + /// Initializes a new instance of . + /// The type of the deployment. + /// Name of the deployment. + /// A new instance for mocking. + public static Deployment Deployment(string type = null, string name = null) { - return new RunStepDeltaFunction(name, arguments, output, serializedAdditionalRawData: null); + return new UnknownDeployment(type == null ? default : new DeploymentType(type), name, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// Reserved for future use. - /// A new instance for mocking. - public static RunStepDeltaFileSearchToolCall RunStepDeltaFileSearchToolCall(int index = default, string id = null, RunStepFileSearchToolCallResults fileSearch = null) + /// Initializes a new instance of . + /// Name of the deployment. + /// Publisher-specific name of the deployed model. + /// Publisher-specific version of the deployed model. + /// Name of the deployed model's publisher. + /// Capabilities of deployed model. + /// Sku of the model deployment. + /// Name of the connection the deployment comes from. + /// A new instance for mocking. + public static ModelDeployment ModelDeployment(string name = null, string modelName = null, string modelVersion = null, string modelPublisher = null, IReadOnlyDictionary capabilities = null, Sku sku = null, string connectionName = null) { - return new RunStepDeltaFileSearchToolCall(index, id, "file_search", serializedAdditionalRawData: null, fileSearch); - } + capabilities ??= new Dictionary(); - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// The Code Interpreter data for the tool call. - /// A new instance for mocking. - public static RunStepDeltaCodeInterpreterToolCall RunStepDeltaCodeInterpreterToolCall(int index = default, string id = null, RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = null) - { - return new RunStepDeltaCodeInterpreterToolCall(index, id, "code_interpreter", serializedAdditionalRawData: null, codeInterpreter); + return new ModelDeployment( + DeploymentType.ModelDeployment, + name, + serializedAdditionalRawData: null, + modelName, + modelVersion, + modelPublisher, + capabilities, + sku, + connectionName); + } + + /// Initializes a new instance of . + /// Sku capacity. + /// Sku family. + /// Sku name. + /// Sku size. + /// Sku tier. + /// A new instance for mocking. + public static Sku Sku(long capacity = default, string family = null, string name = null, string size = null, string tier = null) + { + return new Sku( + capacity, + family, + name, + size, + tier, + serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The input into the Code Interpreter tool call. - /// - /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more - /// items, including text (`logs`) or images (`image`). Each of these are represented by a - /// different object type. - /// 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 . + /// Initializes a new instance of . + /// Identifier of the red team run. + /// Name of the red-team run. + /// Number of simulation rounds. + /// List of attack strategies or nested lists of attack strategies. + /// Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. + /// List of risk categories to generate attack objectives for. + /// Application scenario for the red team operation, to generate scenario specific attacks. + /// Red team's tags. Unlike properties, tags are fully mutable. + /// Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + /// Status of the red-team. It is set by service and is read-only. + /// + /// Target configuration for the red-team 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 . /// - /// A new instance for mocking. - public static RunStepDeltaCodeInterpreterDetailItemObject RunStepDeltaCodeInterpreterDetailItemObject(string input = null, IEnumerable outputs = null) - { - outputs ??= new List(); - - return new RunStepDeltaCodeInterpreterDetailItemObject(input, outputs?.ToList(), serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - /// The type of the streaming run step tool call's Code Interpreter output. - /// A new instance for mocking. - public static RunStepDeltaCodeInterpreterOutput RunStepDeltaCodeInterpreterOutput(int index = default, string type = null) - { - return new UnknownRunStepDeltaCodeInterpreterOutput(index, type, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - /// The text output from the Code Interpreter tool call. - /// A new instance for mocking. - public static RunStepDeltaCodeInterpreterLogOutput RunStepDeltaCodeInterpreterLogOutput(int index = default, string logs = null) + /// A new instance for mocking. + public static RedTeam RedTeam(string name = null, string displayName = null, int? numTurns = null, IEnumerable attackStrategies = null, bool? simulationOnly = null, IEnumerable riskCategories = null, string applicationScenario = null, IDictionary tags = null, IDictionary properties = null, string status = null, TargetConfig target = null) { - return new RunStepDeltaCodeInterpreterLogOutput(index, "logs", serializedAdditionalRawData: null, logs); - } - - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - /// The image data for the Code Interpreter tool call output. - /// A new instance for mocking. - public static RunStepDeltaCodeInterpreterImageOutput RunStepDeltaCodeInterpreterImageOutput(int index = default, RunStepDeltaCodeInterpreterImageOutputObject image = null) - { - return new RunStepDeltaCodeInterpreterImageOutput(index, "image", serializedAdditionalRawData: null, image); - } + attackStrategies ??= new List(); + riskCategories ??= new List(); + tags ??= new Dictionary(); + properties ??= new Dictionary(); - /// Initializes a new instance of . - /// The file ID for the image. - /// A new instance for mocking. - public static RunStepDeltaCodeInterpreterImageOutputObject RunStepDeltaCodeInterpreterImageOutputObject(string fileId = null) - { - return new RunStepDeltaCodeInterpreterImageOutputObject(fileId, serializedAdditionalRawData: null); + return new RedTeam( + name, + displayName, + numTurns, + attackStrategies?.ToList(), + simulationOnly, + riskCategories?.ToList(), + applicationScenario, + tags, + properties, + status, + target, + serializedAdditionalRawData: null); } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.Serialization.cs deleted file mode 100644 index 8d9aa0b28e52..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.Serialization.cs +++ /dev/null @@ -1,197 +0,0 @@ -// 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 AISearchIndexResource : 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(AISearchIndexResource)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("index_connection_id"u8); - writer.WriteStringValue(IndexConnectionId); - writer.WritePropertyName("index_name"u8); - writer.WriteStringValue(IndexName); - if (Optional.IsDefined(QueryType)) - { - writer.WritePropertyName("query_type"u8); - writer.WriteStringValue(QueryType.Value.ToString()); - } - if (Optional.IsDefined(TopK)) - { - writer.WritePropertyName("top_k"u8); - writer.WriteNumberValue(TopK.Value); - } - if (Optional.IsDefined(Filter)) - { - writer.WritePropertyName("filter"u8); - writer.WriteStringValue(Filter); - } - 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 - } - } - } - - AISearchIndexResource 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(AISearchIndexResource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAISearchIndexResource(document.RootElement, options); - } - - internal static AISearchIndexResource DeserializeAISearchIndexResource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string indexConnectionId = default; - string indexName = default; - AzureAISearchQueryType? queryType = default; - int? topK = default; - string filter = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("index_connection_id"u8)) - { - indexConnectionId = property.Value.GetString(); - continue; - } - if (property.NameEquals("index_name"u8)) - { - indexName = property.Value.GetString(); - continue; - } - if (property.NameEquals("query_type"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - queryType = new AzureAISearchQueryType(property.Value.GetString()); - continue; - } - if (property.NameEquals("top_k"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - topK = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("filter"u8)) - { - filter = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AISearchIndexResource( - indexConnectionId, - indexName, - queryType, - topK, - filter, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AISearchIndexResource)} does not support writing '{options.Format}' format."); - } - } - - AISearchIndexResource 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 DeserializeAISearchIndexResource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AISearchIndexResource)} 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 AISearchIndexResource FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAISearchIndexResource(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/AISearchIndexResource.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.cs deleted file mode 100644 index 3958defefe9b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.cs +++ /dev/null @@ -1,94 +0,0 @@ -// 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 AI Search Index resource. - public partial class AISearchIndexResource - { - /// - /// 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 . - /// An index connection id in an IndexResource attached to this agent. - /// The name of an index in an IndexResource attached to this agent. - /// or is null. - public AISearchIndexResource(string indexConnectionId, string indexName) - { - Argument.AssertNotNull(indexConnectionId, nameof(indexConnectionId)); - Argument.AssertNotNull(indexName, nameof(indexName)); - - IndexConnectionId = indexConnectionId; - IndexName = indexName; - } - - /// Initializes a new instance of . - /// An index connection id in an IndexResource attached to this agent. - /// The name of an index in an IndexResource attached to this agent. - /// Type of query in an AIIndexResource attached to this agent. - /// Number of documents to retrieve from search and present to the model. - /// Odata filter string for search resource. - /// Keeps track of any properties unknown to the library. - internal AISearchIndexResource(string indexConnectionId, string indexName, AzureAISearchQueryType? queryType, int? topK, string filter, IDictionary serializedAdditionalRawData) - { - IndexConnectionId = indexConnectionId; - IndexName = indexName; - QueryType = queryType; - TopK = topK; - Filter = filter; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AISearchIndexResource() - { - } - - /// An index connection id in an IndexResource attached to this agent. - public string IndexConnectionId { get; set; } - /// The name of an index in an IndexResource attached to this agent. - public string IndexName { get; set; } - /// Type of query in an AIIndexResource attached to this agent. - public AzureAISearchQueryType? QueryType { get; set; } - /// Number of documents to retrieve from search and present to the model. - public int? TopK { get; set; } - /// Odata filter string for search resource. - public string Filter { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.Serialization.cs deleted file mode 100644 index 6c8eee6cc2a9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 AOAIModelConfig : 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(AOAIModelConfig)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("azureEndpoint"u8); - writer.WriteStringValue(AzureEndpoint); - writer.WritePropertyName("apiKey"u8); - writer.WriteStringValue(ApiKey); - writer.WritePropertyName("azureDeployment"u8); - writer.WriteStringValue(AzureDeployment); - } - - AOAIModelConfig 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(AOAIModelConfig)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAOAIModelConfig(document.RootElement, options); - } - - internal static AOAIModelConfig DeserializeAOAIModelConfig(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string azureEndpoint = default; - string apiKey = default; - string azureDeployment = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("azureEndpoint"u8)) - { - azureEndpoint = property.Value.GetString(); - continue; - } - if (property.NameEquals("apiKey"u8)) - { - apiKey = property.Value.GetString(); - continue; - } - if (property.NameEquals("azureDeployment"u8)) - { - azureDeployment = property.Value.GetString(); - 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 AOAIModelConfig(type, serializedAdditionalRawData, azureEndpoint, apiKey, azureDeployment); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AOAIModelConfig)} does not support writing '{options.Format}' format."); - } - } - - AOAIModelConfig 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 DeserializeAOAIModelConfig(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AOAIModelConfig)} 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 AOAIModelConfig FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAOAIModelConfig(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/AOAIModelConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs deleted file mode 100644 index 1983a0c90b7b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Azure OpenAI model configuration. The API version would be selected by the service for querying the model. - public partial class AOAIModelConfig : TargetModelConfig - { - /// Initializes a new instance of . - /// Endpoint targetURI for AOAI model. - /// API Key for AOAI model. - /// Deployment name for AOAI model. - /// , or is null. - public AOAIModelConfig(string azureEndpoint, string apiKey, string azureDeployment) - { - Argument.AssertNotNull(azureEndpoint, nameof(azureEndpoint)); - Argument.AssertNotNull(apiKey, nameof(apiKey)); - Argument.AssertNotNull(azureDeployment, nameof(azureDeployment)); - - Type = "AOAI"; - AzureEndpoint = azureEndpoint; - ApiKey = apiKey; - AzureDeployment = azureDeployment; - } - - /// Initializes a new instance of . - /// Type of the model configuration. - /// Keeps track of any properties unknown to the library. - /// 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) - { - AzureEndpoint = azureEndpoint; - ApiKey = apiKey; - AzureDeployment = azureDeployment; - } - - /// Initializes a new instance of for deserialization. - internal AOAIModelConfig() - { - } - - /// Endpoint targetURI for AOAI model. - public string AzureEndpoint { get; set; } - /// API Key for AOAI model. - public string ApiKey { get; set; } - /// Deployment name for AOAI model. - public string AzureDeployment { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Agent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Agent.Serialization.cs deleted file mode 100644 index 71f87c864b7a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Agent.Serialization.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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 Agent : 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(Agent)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } - if (Description != null) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - else - { - writer.WriteNull("description"); - } - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); - if (Instructions != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); - } - else - { - writer.WriteNull("instructions"); - } - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } - if (Optional.IsDefined(ResponseFormat)) - { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ResponseFormat); -#else - using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("response_format"); - } - } - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - 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 - } - } - } - - Agent 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(Agent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAgent(document.RootElement, options); - } - - internal static Agent DeserializeAgent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - string @object = default; - DateTimeOffset createdAt = default; - string name = default; - string description = default; - string model = default; - string instructions = default; - IReadOnlyList tools = default; - ToolResources toolResources = default; - float? temperature = default; - float? topP = default; - BinaryData responseFormat = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("name"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("description"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - description = null; - continue; - } - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("instructions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); - continue; - } - if (property.NameEquals("tools"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; - } - if (property.NameEquals("tool_resources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = ToolResources.DeserializeToolResources(property.Value, options); - continue; - } - if (property.NameEquals("temperature"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("top_p"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("response_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new Agent( - id, - @object, - createdAt, - name, - description, - model, - instructions, - tools, - toolResources, - temperature, - topP, - responseFormat, - metadata, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(Agent)} does not support writing '{options.Format}' format."); - } - } - - Agent 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 DeserializeAgent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Agent)} 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 Agent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgent(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/Agent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Agent.cs deleted file mode 100644 index e3dca8de0f79..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Agent.cs +++ /dev/null @@ -1,236 +0,0 @@ -// 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 -{ - /// Represents an agent that can call the model and use tools. - public partial class Agent - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The name of the agent. - /// The description of the agent. - /// The ID of the model to use. - /// The system instructions for the agent to use. - /// - /// 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 . - /// - /// - /// 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` - /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// , or is null. - internal Agent(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, ToolResources toolResources, float? temperature, float? topP, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(model, nameof(model)); - Argument.AssertNotNull(tools, nameof(tools)); - - Id = id; - CreatedAt = createdAt; - Name = name; - Description = description; - Model = model; - Instructions = instructions; - Tools = tools.ToList(); - ToolResources = toolResources; - Temperature = temperature; - TopP = topP; - Metadata = metadata; - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always assistant. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The name of the agent. - /// The description of the agent. - /// The ID of the model to use. - /// The system instructions for the agent to use. - /// - /// 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 . - /// - /// - /// 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` - /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// The response format of the tool calls used by this agent. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal Agent(string id, string @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, ToolResources toolResources, float? temperature, float? topP, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - Name = name; - Description = description; - Model = model; - Instructions = instructions; - Tools = tools; - ToolResources = toolResources; - Temperature = temperature; - TopP = topP; - ResponseFormat = responseFormat; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal Agent() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - - /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } - /// The name of the agent. - public string Name { get; } - /// The description of the agent. - public string Description { get; } - /// The ID of the model to use. - public string Model { get; } - /// The system instructions for the agent to use. - public string Instructions { get; } - /// - /// 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 . - /// - public IReadOnlyList Tools { get; } - /// - /// 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` - /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - public ToolResources ToolResources { get; } - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - public float? Temperature { get; } - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - public float? TopP { get; } - /// - /// The response format of the tool calls used by this agent. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ResponseFormat { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContentObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluation.Serialization.cs similarity index 57% rename from sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContentObject.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluation.Serialization.cs index 8660b0da04b6..c940e64139e4 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContentObject.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluation.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class MessageDeltaTextContentObject : IUtf8JsonSerializable, IJsonModel + public partial class AgentEvaluation : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,22 +28,26 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluation)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Value)) + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + if (Optional.IsDefined(Error)) { - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); } - if (Optional.IsCollectionDefined(Annotations)) + if (Optional.IsCollectionDefined(Result)) { - writer.WritePropertyName("annotations"u8); + writer.WritePropertyName("result"u8); writer.WriteStartArray(); - foreach (var item in Annotations) + foreach (var item in Result) { writer.WriteObjectValue(item, options); } @@ -66,19 +70,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MessageDeltaTextContentObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AgentEvaluation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluation)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextContentObject(document.RootElement, options); + return DeserializeAgentEvaluation(document.RootElement, options); } - internal static MessageDeltaTextContentObject DeserializeMessageDeltaTextContentObject(JsonElement element, ModelReaderWriterOptions options = null) + internal static AgentEvaluation DeserializeAgentEvaluation(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -86,29 +90,41 @@ internal static MessageDeltaTextContentObject DeserializeMessageDeltaTextContent { return null; } - string value = default; - IReadOnlyList annotations = default; + string id = default; + string status = default; + string error = default; + IReadOnlyList result = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (property.NameEquals("id"u8)) { - value = property.Value.GetString(); + id = property.Value.GetString(); continue; } - if (property.NameEquals("annotations"u8)) + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("error"u8)) + { + error = property.Value.GetString(); + continue; + } + if (property.NameEquals("result"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MessageDeltaTextAnnotation.DeserializeMessageDeltaTextAnnotation(item, options)); + array.Add(AgentEvaluationResult.DeserializeAgentEvaluationResult(item, options)); } - annotations = array; + result = array; continue; } if (options.Format != "W") @@ -117,46 +133,46 @@ internal static MessageDeltaTextContentObject DeserializeMessageDeltaTextContent } } serializedAdditionalRawData = rawDataDictionary; - return new MessageDeltaTextContentObject(value, annotations ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new AgentEvaluation(id, status, error, result ?? new ChangeTrackingList(), serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluation)} does not support writing '{options.Format}' format."); } } - MessageDeltaTextContentObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + AgentEvaluation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextContentObject(document.RootElement, options); + return DeserializeAgentEvaluation(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluation)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static MessageDeltaTextContentObject FromResponse(Response response) + internal static AgentEvaluation FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextContentObject(document.RootElement); + return DeserializeAgentEvaluation(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluation.cs similarity index 51% rename from sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluation.cs index 1782ede5ac86..445a1ff982f7 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluation.cs @@ -10,8 +10,8 @@ namespace Azure.AI.Projects { - /// The structure for keeping storage queue name and URI. - public partial class AzureFunctionStorageQueue + /// Evaluation response for agent evaluation run. + public partial class AgentEvaluation { /// /// Keeps track of any properties unknown to the library. @@ -45,38 +45,47 @@ public partial class AzureFunctionStorageQueue /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - /// URI to the Azure Storage Queue service allowing you to manipulate a queue. - /// The name of an Azure function storage queue. - /// or is null. - public AzureFunctionStorageQueue(string storageServiceEndpoint, string queueName) + /// Initializes a new instance of . + /// Identifier of the agent evaluation run. + /// Status of the agent evaluation. Options: Running, Completed, Failed. + /// or is null. + internal AgentEvaluation(string id, string status) { - Argument.AssertNotNull(storageServiceEndpoint, nameof(storageServiceEndpoint)); - Argument.AssertNotNull(queueName, nameof(queueName)); + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(status, nameof(status)); - StorageServiceEndpoint = storageServiceEndpoint; - QueueName = queueName; + Id = id; + Status = status; + Result = new ChangeTrackingList(); } - /// Initializes a new instance of . - /// URI to the Azure Storage Queue service allowing you to manipulate a queue. - /// The name of an Azure function storage queue. + /// Initializes a new instance of . + /// Identifier of the agent evaluation run. + /// Status of the agent evaluation. Options: Running, Completed, Failed. + /// The reason of the request failure for the long running process, if applicable. + /// The agent evaluation result. /// Keeps track of any properties unknown to the library. - internal AzureFunctionStorageQueue(string storageServiceEndpoint, string queueName, IDictionary serializedAdditionalRawData) + internal AgentEvaluation(string id, string status, string error, IReadOnlyList result, IDictionary serializedAdditionalRawData) { - StorageServiceEndpoint = storageServiceEndpoint; - QueueName = queueName; + Id = id; + Status = status; + Error = error; + Result = result; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal AzureFunctionStorageQueue() + /// Initializes a new instance of for deserialization. + internal AgentEvaluation() { } - /// URI to the Azure Storage Queue service allowing you to manipulate a queue. - public string StorageServiceEndpoint { get; set; } - /// The name of an Azure function storage queue. - public string QueueName { get; set; } + /// Identifier of the agent evaluation run. + public string Id { get; } + /// Status of the agent evaluation. Options: Running, Completed, Failed. + public string Status { get; } + /// The reason of the request failure for the long running process, if applicable. + public string Error { get; } + /// The agent evaluation result. + public IReadOnlyList Result { get; } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoice.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRedactionConfiguration.Serialization.cs similarity index 60% rename from sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoice.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRedactionConfiguration.Serialization.cs index 2d1ecc9338c6..33d799d4dc50 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoice.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRedactionConfiguration.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class AgentsNamedToolChoice : IUtf8JsonSerializable, IJsonModel + public partial class AgentEvaluationRedactionConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,18 +28,16 @@ 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AgentsNamedToolChoice)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationRedactionConfiguration)} does not support writing '{format}' format."); } - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - if (Optional.IsDefined(Function)) + if (Optional.IsDefined(RedactScoreProperties)) { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(Function, options); + writer.WritePropertyName("redactScoreProperties"u8); + writer.WriteBooleanValue(RedactScoreProperties.Value); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -58,19 +56,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AgentsNamedToolChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AgentEvaluationRedactionConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AgentsNamedToolChoice)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationRedactionConfiguration)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAgentsNamedToolChoice(document.RootElement, options); + return DeserializeAgentEvaluationRedactionConfiguration(document.RootElement, options); } - internal static AgentsNamedToolChoice DeserializeAgentsNamedToolChoice(JsonElement element, ModelReaderWriterOptions options = null) + internal static AgentEvaluationRedactionConfiguration DeserializeAgentEvaluationRedactionConfiguration(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -78,24 +76,18 @@ internal static AgentsNamedToolChoice DeserializeAgentsNamedToolChoice(JsonEleme { return null; } - AgentsNamedToolChoiceType type = default; - FunctionName function = default; + bool? redactScoreProperties = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("type"u8)) - { - type = new AgentsNamedToolChoiceType(property.Value.GetString()); - continue; - } - if (property.NameEquals("function"u8)) + if (property.NameEquals("redactScoreProperties"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - function = FunctionName.DeserializeFunctionName(property.Value, options); + redactScoreProperties = property.Value.GetBoolean(); continue; } if (options.Format != "W") @@ -104,46 +96,46 @@ internal static AgentsNamedToolChoice DeserializeAgentsNamedToolChoice(JsonEleme } } serializedAdditionalRawData = rawDataDictionary; - return new AgentsNamedToolChoice(type, function, serializedAdditionalRawData); + return new AgentEvaluationRedactionConfiguration(redactScoreProperties, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(AgentsNamedToolChoice)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationRedactionConfiguration)} does not support writing '{options.Format}' format."); } } - AgentsNamedToolChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + AgentEvaluationRedactionConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentsNamedToolChoice(document.RootElement, options); + return DeserializeAgentEvaluationRedactionConfiguration(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(AgentsNamedToolChoice)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationRedactionConfiguration)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static AgentsNamedToolChoice FromResponse(Response response) + internal static AgentEvaluationRedactionConfiguration FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentsNamedToolChoice(document.RootElement); + return DeserializeAgentEvaluationRedactionConfiguration(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormat.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRedactionConfiguration.cs similarity index 69% rename from sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormat.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRedactionConfiguration.cs index b481792951e0..29f07516faca 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormat.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRedactionConfiguration.cs @@ -10,11 +10,8 @@ namespace Azure.AI.Projects { - /// - /// An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. - /// If `text` the model can return text or any value needed. - /// - public partial class AgentsApiResponseFormat + /// The redaction configuration will allow the user to control what is redacted. + public partial class AgentEvaluationRedactionConfiguration { /// /// Keeps track of any properties unknown to the library. @@ -48,21 +45,21 @@ public partial class AgentsApiResponseFormat /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - public AgentsApiResponseFormat() + /// Initializes a new instance of . + public AgentEvaluationRedactionConfiguration() { } - /// Initializes a new instance of . - /// Must be one of `text` or `json_object`. + /// Initializes a new instance of . + /// Redact score properties. If not specified, the default is to redact in production. /// Keeps track of any properties unknown to the library. - internal AgentsApiResponseFormat(ResponseFormat? type, IDictionary serializedAdditionalRawData) + internal AgentEvaluationRedactionConfiguration(bool? redactScoreProperties, IDictionary serializedAdditionalRawData) { - Type = type; + RedactScoreProperties = redactScoreProperties; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Must be one of `text` or `json_object`. - public ResponseFormat? Type { get; set; } + /// Redact score properties. If not specified, the default is to redact in production. + public bool? RedactScoreProperties { get; set; } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolResource.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRequest.Serialization.cs similarity index 50% rename from sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolResource.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRequest.Serialization.cs index e1e8d6e5aa33..ca242f61c9a6 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolResource.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRequest.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class FileSearchToolResource : IUtf8JsonSerializable, IJsonModel + public partial class AgentEvaluationRequest : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,32 +28,39 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationRequest)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(VectorStoreIds)) + writer.WritePropertyName("runId"u8); + writer.WriteStringValue(RunId); + if (Optional.IsDefined(ThreadId)) { - writer.WritePropertyName("vector_store_ids"u8); - writer.WriteStartArray(); - foreach (var item in VectorStoreIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WritePropertyName("threadId"u8); + writer.WriteStringValue(ThreadId); } - if (Optional.IsCollectionDefined(VectorStores)) + writer.WritePropertyName("evaluators"u8); + writer.WriteStartObject(); + foreach (var item in Evaluators) { - writer.WritePropertyName("vector_stores"u8); - writer.WriteStartArray(); - foreach (var item in VectorStores) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (Optional.IsDefined(SamplingConfiguration)) + { + writer.WritePropertyName("samplingConfiguration"u8); + writer.WriteObjectValue(SamplingConfiguration, options); + } + if (Optional.IsDefined(RedactionConfiguration)) + { + writer.WritePropertyName("redactionConfiguration"u8); + writer.WriteObjectValue(RedactionConfiguration, options); } + writer.WritePropertyName("appInsightsConnectionString"u8); + writer.WriteStringValue(AppInsightsConnectionString); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -71,19 +78,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - FileSearchToolResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AgentEvaluationRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationRequest)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileSearchToolResource(document.RootElement, options); + return DeserializeAgentEvaluationRequest(document.RootElement, options); } - internal static FileSearchToolResource DeserializeFileSearchToolResource(JsonElement element, ModelReaderWriterOptions options = null) + internal static AgentEvaluationRequest DeserializeAgentEvaluationRequest(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -91,38 +98,57 @@ internal static FileSearchToolResource DeserializeFileSearchToolResource(JsonEle { return null; } - IList vectorStoreIds = default; - IList vectorStores = default; + string runId = default; + string threadId = default; + IDictionary evaluators = default; + AgentEvaluationSamplingConfiguration samplingConfiguration = default; + AgentEvaluationRedactionConfiguration redactionConfiguration = default; + string appInsightsConnectionString = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("vector_store_ids"u8)) + if (property.NameEquals("runId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("threadId"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("evaluators"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - array.Add(item.GetString()); + dictionary.Add(property0.Name, EvaluatorConfiguration.DeserializeEvaluatorConfiguration(property0.Value, options)); } - vectorStoreIds = array; + evaluators = dictionary; continue; } - if (property.NameEquals("vector_stores"u8)) + if (property.NameEquals("samplingConfiguration"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + samplingConfiguration = AgentEvaluationSamplingConfiguration.DeserializeAgentEvaluationSamplingConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("redactionConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - array.Add(VectorStoreConfigurations.DeserializeVectorStoreConfigurations(item, options)); + continue; } - vectorStores = array; + redactionConfiguration = AgentEvaluationRedactionConfiguration.DeserializeAgentEvaluationRedactionConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("appInsightsConnectionString"u8)) + { + appInsightsConnectionString = property.Value.GetString(); continue; } if (options.Format != "W") @@ -131,46 +157,53 @@ internal static FileSearchToolResource DeserializeFileSearchToolResource(JsonEle } } serializedAdditionalRawData = rawDataDictionary; - return new FileSearchToolResource(vectorStoreIds ?? new ChangeTrackingList(), vectorStores ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new AgentEvaluationRequest( + runId, + threadId, + evaluators, + samplingConfiguration, + redactionConfiguration, + appInsightsConnectionString, + serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationRequest)} does not support writing '{options.Format}' format."); } } - FileSearchToolResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + AgentEvaluationRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFileSearchToolResource(document.RootElement, options); + return DeserializeAgentEvaluationRequest(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationRequest)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static FileSearchToolResource FromResponse(Response response) + internal static AgentEvaluationRequest FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFileSearchToolResource(document.RootElement); + return DeserializeAgentEvaluationRequest(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRequest.cs new file mode 100644 index 000000000000..941832665a14 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationRequest.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Evaluation request for agent run. + public partial class AgentEvaluationRequest + { + /// + /// 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 . + /// Identifier of the agent run. + /// Evaluators to be used for the evaluation. + /// Pass the AppInsights connection string to the agent evaluation for the evaluation results and the errors logs. + /// , or is null. + public AgentEvaluationRequest(string runId, IDictionary evaluators, string appInsightsConnectionString) + { + Argument.AssertNotNull(runId, nameof(runId)); + Argument.AssertNotNull(evaluators, nameof(evaluators)); + Argument.AssertNotNull(appInsightsConnectionString, nameof(appInsightsConnectionString)); + + RunId = runId; + Evaluators = evaluators; + AppInsightsConnectionString = appInsightsConnectionString; + } + + /// Initializes a new instance of . + /// Identifier of the agent run. + /// Identifier of the agent thread. This field is mandatory currently, but it will be optional in the future. + /// Evaluators to be used for the evaluation. + /// Sampling configuration for the evaluation. + /// Redaction configuration for the evaluation. + /// Pass the AppInsights connection string to the agent evaluation for the evaluation results and the errors logs. + /// Keeps track of any properties unknown to the library. + internal AgentEvaluationRequest(string runId, string threadId, IDictionary evaluators, AgentEvaluationSamplingConfiguration samplingConfiguration, AgentEvaluationRedactionConfiguration redactionConfiguration, string appInsightsConnectionString, IDictionary serializedAdditionalRawData) + { + RunId = runId; + ThreadId = threadId; + Evaluators = evaluators; + SamplingConfiguration = samplingConfiguration; + RedactionConfiguration = redactionConfiguration; + AppInsightsConnectionString = appInsightsConnectionString; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AgentEvaluationRequest() + { + } + + /// Identifier of the agent run. + public string RunId { get; } + /// Identifier of the agent thread. This field is mandatory currently, but it will be optional in the future. + public string ThreadId { get; set; } + /// Evaluators to be used for the evaluation. + public IDictionary Evaluators { get; } + /// Sampling configuration for the evaluation. + public AgentEvaluationSamplingConfiguration SamplingConfiguration { get; set; } + /// Redaction configuration for the evaluation. + public AgentEvaluationRedactionConfiguration RedactionConfiguration { get; set; } + /// Pass the AppInsights connection string to the agent evaluation for the evaluation results and the errors logs. + public string AppInsightsConnectionString { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationResult.Serialization.cs new file mode 100644 index 000000000000..a6ee774b8f5e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationResult.Serialization.cs @@ -0,0 +1,255 @@ +// 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 AgentEvaluationResult : 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(AgentEvaluationResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("evaluator"u8); + writer.WriteStringValue(Evaluator); + writer.WritePropertyName("evaluatorId"u8); + writer.WriteStringValue(EvaluatorId); + writer.WritePropertyName("score"u8); + writer.WriteNumberValue(Score); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + } + if (Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsDefined(ThreadId)) + { + writer.WritePropertyName("threadId"u8); + writer.WriteStringValue(ThreadId); + } + writer.WritePropertyName("runId"u8); + writer.WriteStringValue(RunId); + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); + } + if (Optional.IsCollectionDefined(AdditionalDetails)) + { + writer.WritePropertyName("additionalDetails"u8); + writer.WriteStartObject(); + foreach (var item in AdditionalDetails) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + 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 + } + } + } + + AgentEvaluationResult 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(AgentEvaluationResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentEvaluationResult(document.RootElement, options); + } + + internal static AgentEvaluationResult DeserializeAgentEvaluationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string evaluator = default; + string evaluatorId = default; + float score = default; + string status = default; + string reason = default; + string version = default; + string threadId = default; + string runId = default; + string error = default; + IReadOnlyDictionary additionalDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("evaluator"u8)) + { + evaluator = property.Value.GetString(); + continue; + } + if (property.NameEquals("evaluatorId"u8)) + { + evaluatorId = property.Value.GetString(); + continue; + } + if (property.NameEquals("score"u8)) + { + score = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("reason"u8)) + { + reason = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("threadId"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("runId"u8)) + { + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("error"u8)) + { + error = property.Value.GetString(); + continue; + } + if (property.NameEquals("additionalDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + additionalDetails = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AgentEvaluationResult( + evaluator, + evaluatorId, + score, + status, + reason, + version, + threadId, + runId, + error, + additionalDetails ?? new ChangeTrackingDictionary(), + 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, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AgentEvaluationResult)} does not support writing '{options.Format}' format."); + } + } + + AgentEvaluationResult 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 DeserializeAgentEvaluationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentEvaluationResult)} 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 AgentEvaluationResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentEvaluationResult(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/AgentEvaluationResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationResult.cs new file mode 100644 index 000000000000..7e1a9fd0b5e9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationResult.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Result for the agent evaluation evaluator run. + public partial class AgentEvaluationResult + { + /// + /// 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 . + /// Evaluator's name. This is the name of the evaluator that was used to evaluate the agent's completion. + /// Identifier of the evaluator. + /// Score of the given evaluator. No restriction on range. + /// Status of the evaluator result. Options: Running, Completed, Failed, NotApplicable. + /// The unique identifier of the run. + /// , , or is null. + internal AgentEvaluationResult(string evaluator, string evaluatorId, float score, string status, string runId) + { + Argument.AssertNotNull(evaluator, nameof(evaluator)); + Argument.AssertNotNull(evaluatorId, nameof(evaluatorId)); + Argument.AssertNotNull(status, nameof(status)); + Argument.AssertNotNull(runId, nameof(runId)); + + Evaluator = evaluator; + EvaluatorId = evaluatorId; + Score = score; + Status = status; + RunId = runId; + AdditionalDetails = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Evaluator's name. This is the name of the evaluator that was used to evaluate the agent's completion. + /// Identifier of the evaluator. + /// Score of the given evaluator. No restriction on range. + /// Status of the evaluator result. Options: Running, Completed, Failed, NotApplicable. + /// Reasoning for the evaluation result. + /// Version of the evaluator that was used to evaluate the agent's completion. + /// The unique identifier of the thread. + /// The unique identifier of the run. + /// A string explaining why there was an error, if applicable. + /// Additional properties relevant to the evaluator. These will differ between evaluators. + /// Keeps track of any properties unknown to the library. + internal AgentEvaluationResult(string evaluator, string evaluatorId, float score, string status, string reason, string version, string threadId, string runId, string error, IReadOnlyDictionary additionalDetails, IDictionary serializedAdditionalRawData) + { + Evaluator = evaluator; + EvaluatorId = evaluatorId; + Score = score; + Status = status; + Reason = reason; + Version = version; + ThreadId = threadId; + RunId = runId; + Error = error; + AdditionalDetails = additionalDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AgentEvaluationResult() + { + } + + /// Evaluator's name. This is the name of the evaluator that was used to evaluate the agent's completion. + public string Evaluator { get; } + /// Identifier of the evaluator. + public string EvaluatorId { get; } + /// Score of the given evaluator. No restriction on range. + public float Score { get; } + /// Status of the evaluator result. Options: Running, Completed, Failed, NotApplicable. + public string Status { get; } + /// Reasoning for the evaluation result. + public string Reason { get; } + /// Version of the evaluator that was used to evaluate the agent's completion. + public string Version { get; } + /// The unique identifier of the thread. + public string ThreadId { get; } + /// The unique identifier of the run. + public string RunId { get; } + /// A string explaining why there was an error, if applicable. + public string Error { get; } + /// Additional properties relevant to the evaluator. These will differ between evaluators. + public IReadOnlyDictionary AdditionalDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationSamplingConfiguration.Serialization.cs similarity index 60% rename from sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationSamplingConfiguration.Serialization.cs index 10ca8b928f60..95691048d7ff 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationSamplingConfiguration.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class RunStepCodeInterpreterImageReference : IUtf8JsonSerializable, IJsonModel + public partial class AgentEvaluationSamplingConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,14 +28,18 @@ 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationSamplingConfiguration)} does not support writing '{format}' format."); } - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("samplingPercent"u8); + writer.WriteNumberValue(SamplingPercent); + writer.WritePropertyName("maxRequestRate"u8); + writer.WriteNumberValue(MaxRequestRate); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -53,19 +57,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RunStepCodeInterpreterImageReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AgentEvaluationSamplingConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationSamplingConfiguration)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCodeInterpreterImageReference(document.RootElement, options); + return DeserializeAgentEvaluationSamplingConfiguration(document.RootElement, options); } - internal static RunStepCodeInterpreterImageReference DeserializeRunStepCodeInterpreterImageReference(JsonElement element, ModelReaderWriterOptions options = null) + internal static AgentEvaluationSamplingConfiguration DeserializeAgentEvaluationSamplingConfiguration(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -73,14 +77,26 @@ internal static RunStepCodeInterpreterImageReference DeserializeRunStepCodeInter { return null; } - string fileId = default; + string name = default; + float samplingPercent = default; + float maxRequestRate = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("file_id"u8)) + if (property.NameEquals("name"u8)) { - fileId = property.Value.GetString(); + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("samplingPercent"u8)) + { + samplingPercent = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("maxRequestRate"u8)) + { + maxRequestRate = property.Value.GetSingle(); continue; } if (options.Format != "W") @@ -89,46 +105,46 @@ internal static RunStepCodeInterpreterImageReference DeserializeRunStepCodeInter } } serializedAdditionalRawData = rawDataDictionary; - return new RunStepCodeInterpreterImageReference(fileId, serializedAdditionalRawData); + return new AgentEvaluationSamplingConfiguration(name, samplingPercent, maxRequestRate, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationSamplingConfiguration)} does not support writing '{options.Format}' format."); } } - RunStepCodeInterpreterImageReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + AgentEvaluationSamplingConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepCodeInterpreterImageReference(document.RootElement, options); + return DeserializeAgentEvaluationSamplingConfiguration(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(AgentEvaluationSamplingConfiguration)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static RunStepCodeInterpreterImageReference FromResponse(Response response) + internal static AgentEvaluationSamplingConfiguration FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepCodeInterpreterImageReference(document.RootElement); + return DeserializeAgentEvaluationSamplingConfiguration(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationSamplingConfiguration.cs similarity index 53% rename from sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationSamplingConfiguration.cs index 86898f39d812..c984403bfaae 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentEvaluationSamplingConfiguration.cs @@ -10,8 +10,8 @@ namespace Azure.AI.Projects { - /// The structure for keeping storage queue name and URI. - public partial class AzureFunctionBinding + /// Definition for sampling strategy. + public partial class AgentEvaluationSamplingConfiguration { /// /// Keeps track of any properties unknown to the library. @@ -45,36 +45,43 @@ public partial class AzureFunctionBinding /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - /// Storage queue. - /// is null. - public AzureFunctionBinding(AzureFunctionStorageQueue storageQueue) + /// Initializes a new instance of . + /// Name of the sampling strategy. + /// Percentage of sampling per hour (0-100). + /// Maximum request rate per hour (0 to 1000). + /// is null. + public AgentEvaluationSamplingConfiguration(string name, float samplingPercent, float maxRequestRate) { - Argument.AssertNotNull(storageQueue, nameof(storageQueue)); + Argument.AssertNotNull(name, nameof(name)); - StorageQueue = storageQueue; + Name = name; + SamplingPercent = samplingPercent; + MaxRequestRate = maxRequestRate; } - /// Initializes a new instance of . - /// The type of binding, which is always 'storage_queue'. - /// Storage queue. + /// Initializes a new instance of . + /// Name of the sampling strategy. + /// Percentage of sampling per hour (0-100). + /// Maximum request rate per hour (0 to 1000). /// Keeps track of any properties unknown to the library. - internal AzureFunctionBinding(AzureFunctionBindingType type, AzureFunctionStorageQueue storageQueue, IDictionary serializedAdditionalRawData) + internal AgentEvaluationSamplingConfiguration(string name, float samplingPercent, float maxRequestRate, IDictionary serializedAdditionalRawData) { - Type = type; - StorageQueue = storageQueue; + Name = name; + SamplingPercent = samplingPercent; + MaxRequestRate = maxRequestRate; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal AzureFunctionBinding() + /// Initializes a new instance of for deserialization. + internal AgentEvaluationSamplingConfiguration() { } - /// The type of binding, which is always 'storage_queue'. - public AzureFunctionBindingType Type { get; } = AzureFunctionBindingType.StorageQueue; - - /// Storage queue. - public AzureFunctionStorageQueue StorageQueue { get; set; } + /// Name of the sampling strategy. + public string Name { get; } + /// Percentage of sampling per hour (0-100). + public float SamplingPercent { get; } + /// Maximum request rate per hour (0 to 1000). + public float MaxRequestRate { get; } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentFile.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentFile.Serialization.cs deleted file mode 100644 index bbf8e7ac4208..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentFile.Serialization.cs +++ /dev/null @@ -1,217 +0,0 @@ -// 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 AgentFile : 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(AgentFile)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object); - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("bytes"u8); - writer.WriteNumberValue(Size); - writer.WritePropertyName("filename"u8); - writer.WriteStringValue(Filename); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - writer.WritePropertyName("purpose"u8); - writer.WriteStringValue(Purpose.ToString()); - if (Optional.IsDefined(Status)) - { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.Value.ToString()); - } - if (Optional.IsDefined(StatusDetails)) - { - writer.WritePropertyName("status_details"u8); - writer.WriteStringValue(StatusDetails); - } - 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 - } - } - } - - AgentFile 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(AgentFile)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAgentFile(document.RootElement, options); - } - - internal static AgentFile DeserializeAgentFile(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string @object = default; - string id = default; - int bytes = default; - string filename = default; - DateTimeOffset createdAt = default; - AgentFilePurpose purpose = default; - FileState? status = default; - string statusDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = property.Value.GetString(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("bytes"u8)) - { - DeserializeNullableSize(property, ref bytes); - continue; - } - if (property.NameEquals("filename"u8)) - { - filename = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("purpose"u8)) - { - purpose = new AgentFilePurpose(property.Value.GetString()); - continue; - } - if (property.NameEquals("status"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - status = new FileState(property.Value.GetString()); - continue; - } - if (property.NameEquals("status_details"u8)) - { - statusDetails = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AgentFile( - @object, - id, - bytes, - filename, - createdAt, - purpose, - status, - statusDetails, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AgentFile)} does not support writing '{options.Format}' format."); - } - } - - AgentFile 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 DeserializeAgentFile(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AgentFile)} 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 AgentFile FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentFile(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/AgentFile.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentFile.cs deleted file mode 100644 index 69b2db4aa1b8..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentFile.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents an agent that can call the model and use tools. - public partial class AgentFile - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// The size of the file, in bytes. - /// The name of the file. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The intended purpose of a file. - /// or is null. - internal AgentFile(string id, int size, string filename, DateTimeOffset createdAt, AgentFilePurpose purpose) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(filename, nameof(filename)); - - Id = id; - Size = size; - Filename = filename; - CreatedAt = createdAt; - Purpose = purpose; - } - - /// Initializes a new instance of . - /// The object type, which is always 'file'. - /// The identifier, which can be referenced in API endpoints. - /// The size of the file, in bytes. - /// The name of the file. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The intended purpose of a file. - /// The state of the file. This field is available in Azure OpenAI only. - /// The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. - /// Keeps track of any properties unknown to the library. - internal AgentFile(string @object, string id, int size, string filename, DateTimeOffset createdAt, AgentFilePurpose purpose, FileState? status, string statusDetails, IDictionary serializedAdditionalRawData) - { - Object = @object; - Id = id; - Size = size; - Filename = filename; - CreatedAt = createdAt; - Purpose = purpose; - Status = status; - StatusDetails = statusDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AgentFile() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - /// The size of the file, in bytes. - public int Size { get; } - /// The name of the file. - public string Filename { get; } - /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } - /// The intended purpose of a file. - public AgentFilePurpose Purpose { get; } - /// The state of the file. This field is available in Azure OpenAI only. - public FileState? Status { get; } - /// The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. - public string StatusDetails { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentFilePurpose.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentFilePurpose.cs deleted file mode 100644 index 825a6ce4fe43..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentFilePurpose.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The possible values denoting the intended usage of a file. - public readonly partial struct AgentFilePurpose : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AgentFilePurpose(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string FineTuneValue = "fine-tune"; - private const string FineTuneResultsValue = "fine-tune-results"; - private const string AgentsValue = "assistants"; - private const string AgentsOutputValue = "assistants_output"; - private const string BatchValue = "batch"; - private const string BatchOutputValue = "batch_output"; - private const string VisionValue = "vision"; - - /// Indicates a file is used for fine tuning input. - public static AgentFilePurpose FineTune { get; } = new AgentFilePurpose(FineTuneValue); - /// Indicates a file is used for fine tuning results. - public static AgentFilePurpose FineTuneResults { get; } = new AgentFilePurpose(FineTuneResultsValue); - /// Indicates a file is used as input to agents. - public static AgentFilePurpose Agents { get; } = new AgentFilePurpose(AgentsValue); - /// Indicates a file is used as output by agents. - public static AgentFilePurpose AgentsOutput { get; } = new AgentFilePurpose(AgentsOutputValue); - /// Indicates a file is used as input to . - public static AgentFilePurpose Batch { get; } = new AgentFilePurpose(BatchValue); - /// Indicates a file is used as output by a vector store batch operation. - public static AgentFilePurpose BatchOutput { get; } = new AgentFilePurpose(BatchOutputValue); - /// Indicates a file is used as input to a vision operation. - public static AgentFilePurpose Vision { get; } = new AgentFilePurpose(VisionValue); - /// Determines if two values are the same. - public static bool operator ==(AgentFilePurpose left, AgentFilePurpose right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(AgentFilePurpose left, AgentFilePurpose right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AgentFilePurpose(string value) => new AgentFilePurpose(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AgentFilePurpose other && Equals(other); - /// - public bool Equals(AgentFilePurpose 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/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStore.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStore.Serialization.cs deleted file mode 100644 index 7ec74eea2e7b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStore.Serialization.cs +++ /dev/null @@ -1,190 +0,0 @@ -// 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 AgentPageableListOfVectorStore : 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(AgentPageableListOfVectorStore)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - 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 - } - } - } - - AgentPageableListOfVectorStore 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(AgentPageableListOfVectorStore)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAgentPageableListOfVectorStore(document.RootElement, options); - } - - internal static AgentPageableListOfVectorStore DeserializeAgentPageableListOfVectorStore(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AgentPageableListOfVectorStoreObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = new AgentPageableListOfVectorStoreObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(VectorStore.DeserializeVectorStore(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AgentPageableListOfVectorStore( - @object, - data, - firstId, - lastId, - hasMore, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AgentPageableListOfVectorStore)} does not support writing '{options.Format}' format."); - } - } - - AgentPageableListOfVectorStore 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 DeserializeAgentPageableListOfVectorStore(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AgentPageableListOfVectorStore)} 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 AgentPageableListOfVectorStore FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentPageableListOfVectorStore(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/AgentPageableListOfVectorStore.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStore.cs deleted file mode 100644 index 2ea6213ac2b7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStore.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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 -{ - /// The response data for a requested list of items. - public partial class AgentPageableListOfVectorStore - { - /// - /// 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 requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// , or is null. - internal AgentPageableListOfVectorStore(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// Keeps track of any properties unknown to the library. - internal AgentPageableListOfVectorStore(AgentPageableListOfVectorStoreObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AgentPageableListOfVectorStore() - { - } - - /// The object type, which is always list. - public AgentPageableListOfVectorStoreObject Object { get; } = AgentPageableListOfVectorStoreObject.List; - - /// The requested list of items. - public IReadOnlyList Data { get; } - /// The first ID represented in this list. - public string FirstId { get; } - /// The last ID represented in this list. - public string LastId { get; } - /// A value indicating whether there are additional values available not captured in this list. - public bool HasMore { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreFile.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreFile.Serialization.cs deleted file mode 100644 index 8bf15aabdaf3..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreFile.Serialization.cs +++ /dev/null @@ -1,190 +0,0 @@ -// 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 AgentPageableListOfVectorStoreFile : 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(AgentPageableListOfVectorStoreFile)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - 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 - } - } - } - - AgentPageableListOfVectorStoreFile 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(AgentPageableListOfVectorStoreFile)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAgentPageableListOfVectorStoreFile(document.RootElement, options); - } - - internal static AgentPageableListOfVectorStoreFile DeserializeAgentPageableListOfVectorStoreFile(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AgentPageableListOfVectorStoreFileObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = new AgentPageableListOfVectorStoreFileObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(VectorStoreFile.DeserializeVectorStoreFile(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AgentPageableListOfVectorStoreFile( - @object, - data, - firstId, - lastId, - hasMore, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AgentPageableListOfVectorStoreFile)} does not support writing '{options.Format}' format."); - } - } - - AgentPageableListOfVectorStoreFile 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 DeserializeAgentPageableListOfVectorStoreFile(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AgentPageableListOfVectorStoreFile)} 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 AgentPageableListOfVectorStoreFile FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentPageableListOfVectorStoreFile(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/AgentPageableListOfVectorStoreFile.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreFile.cs deleted file mode 100644 index d8d7fdb4b541..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreFile.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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 -{ - /// The response data for a requested list of items. - public partial class AgentPageableListOfVectorStoreFile - { - /// - /// 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 requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// , or is null. - internal AgentPageableListOfVectorStoreFile(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// Keeps track of any properties unknown to the library. - internal AgentPageableListOfVectorStoreFile(AgentPageableListOfVectorStoreFileObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AgentPageableListOfVectorStoreFile() - { - } - - /// The object type, which is always list. - public AgentPageableListOfVectorStoreFileObject Object { get; } = AgentPageableListOfVectorStoreFileObject.List; - - /// The requested list of items. - public IReadOnlyList Data { get; } - /// The first ID represented in this list. - public string FirstId { get; } - /// The last ID represented in this list. - public string LastId { get; } - /// A value indicating whether there are additional values available not captured in this list. - public bool HasMore { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreFileObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreFileObject.cs deleted file mode 100644 index 6adb77310e98..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreFileObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The OpenAIPageableListOfVectorStoreFile_object. - public readonly partial struct AgentPageableListOfVectorStoreFileObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AgentPageableListOfVectorStoreFileObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static AgentPageableListOfVectorStoreFileObject List { get; } = new AgentPageableListOfVectorStoreFileObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(AgentPageableListOfVectorStoreFileObject left, AgentPageableListOfVectorStoreFileObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(AgentPageableListOfVectorStoreFileObject left, AgentPageableListOfVectorStoreFileObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AgentPageableListOfVectorStoreFileObject(string value) => new AgentPageableListOfVectorStoreFileObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AgentPageableListOfVectorStoreFileObject other && Equals(other); - /// - public bool Equals(AgentPageableListOfVectorStoreFileObject 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/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreObject.cs deleted file mode 100644 index 38c4b09c239a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentPageableListOfVectorStoreObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The OpenAIPageableListOfVectorStore_object. - public readonly partial struct AgentPageableListOfVectorStoreObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AgentPageableListOfVectorStoreObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static AgentPageableListOfVectorStoreObject List { get; } = new AgentPageableListOfVectorStoreObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(AgentPageableListOfVectorStoreObject left, AgentPageableListOfVectorStoreObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(AgentPageableListOfVectorStoreObject left, AgentPageableListOfVectorStoreObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AgentPageableListOfVectorStoreObject(string value) => new AgentPageableListOfVectorStoreObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AgentPageableListOfVectorStoreObject other && Equals(other); - /// - public bool Equals(AgentPageableListOfVectorStoreObject 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/sdk/ai/Azure.AI.Projects/src/Generated/AgentStreamEvent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentStreamEvent.cs deleted file mode 100644 index 97c4efa2a29e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentStreamEvent.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// - /// Each event in a server-sent events stream has an `event` and `data` property: - /// - /// ``` - /// event: thread.created - /// data: {"id": "thread_123", "object": "thread", ...} - /// ``` - /// - /// We emit events whenever a new object is created, transitions to a new state, or is being - /// streamed in parts (deltas). For example, we emit `thread.run.created` when a new run - /// is created, `thread.run.completed` when a run completes, and so on. When an Agent chooses - /// to create a message during a run, we emit a `thread.message.created event`, a - /// `thread.message.in_progress` event, many `thread.message.delta` events, and finally a - /// `thread.message.completed` event. - /// - /// We may add additional events over time, so we recommend handling unknown events gracefully - /// in your code. - /// - public readonly partial struct AgentStreamEvent : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AgentStreamEvent(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ThreadCreatedValue = "thread.created"; - private const string ThreadRunCreatedValue = "thread.run.created"; - private const string ThreadRunQueuedValue = "thread.run.queued"; - private const string ThreadRunInProgressValue = "thread.run.in_progress"; - private const string ThreadRunRequiresActionValue = "thread.run.requires_action"; - private const string ThreadRunCompletedValue = "thread.run.completed"; - private const string ThreadRunIncompleteValue = "thread.run.incomplete"; - private const string ThreadRunFailedValue = "thread.run.failed"; - private const string ThreadRunCancellingValue = "thread.run.cancelling"; - private const string ThreadRunCancelledValue = "thread.run.cancelled"; - private const string ThreadRunExpiredValue = "thread.run.expired"; - private const string ThreadRunStepCreatedValue = "thread.run.step.created"; - private const string ThreadRunStepInProgressValue = "thread.run.step.in_progress"; - private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; - private const string ThreadRunStepCompletedValue = "thread.run.step.completed"; - private const string ThreadRunStepFailedValue = "thread.run.step.failed"; - private const string ThreadRunStepCancelledValue = "thread.run.step.cancelled"; - private const string ThreadRunStepExpiredValue = "thread.run.step.expired"; - private const string ThreadMessageCreatedValue = "thread.message.created"; - private const string ThreadMessageInProgressValue = "thread.message.in_progress"; - private const string ThreadMessageDeltaValue = "thread.message.delta"; - private const string ThreadMessageCompletedValue = "thread.message.completed"; - private const string ThreadMessageIncompleteValue = "thread.message.incomplete"; - private const string ErrorValue = "error"; - private const string DoneValue = "done"; - - /// Event sent when a new thread is created. The data of this event is of type AgentThread. - public static AgentStreamEvent ThreadCreated { get; } = new AgentStreamEvent(ThreadCreatedValue); - /// Event sent when a new run is created. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunCreated { get; } = new AgentStreamEvent(ThreadRunCreatedValue); - /// Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunQueued { get; } = new AgentStreamEvent(ThreadRunQueuedValue); - /// Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunInProgress { get; } = new AgentStreamEvent(ThreadRunInProgressValue); - /// Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunRequiresAction { get; } = new AgentStreamEvent(ThreadRunRequiresActionValue); - /// Event sent when a run is completed. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunCompleted { get; } = new AgentStreamEvent(ThreadRunCompletedValue); - /// Event sent when a run ends incomplete. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunIncomplete { get; } = new AgentStreamEvent(ThreadRunIncompleteValue); - /// Event sent when a run fails. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunFailed { get; } = new AgentStreamEvent(ThreadRunFailedValue); - /// Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunCancelling { get; } = new AgentStreamEvent(ThreadRunCancellingValue); - /// Event sent when a run is cancelled. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunCancelled { get; } = new AgentStreamEvent(ThreadRunCancelledValue); - /// Event sent when a run is expired. The data of this event is of type ThreadRun. - public static AgentStreamEvent ThreadRunExpired { get; } = new AgentStreamEvent(ThreadRunExpiredValue); - /// Event sent when a new thread run step is created. The data of this event is of type RunStep. - public static AgentStreamEvent ThreadRunStepCreated { get; } = new AgentStreamEvent(ThreadRunStepCreatedValue); - /// Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep. - public static AgentStreamEvent ThreadRunStepInProgress { get; } = new AgentStreamEvent(ThreadRunStepInProgressValue); - /// Event sent when a run step is being streamed. The data of this event is of type RunStepDeltaChunk. - public static AgentStreamEvent ThreadRunStepDelta { get; } = new AgentStreamEvent(ThreadRunStepDeltaValue); - /// Event sent when a run step is completed. The data of this event is of type RunStep. - public static AgentStreamEvent ThreadRunStepCompleted { get; } = new AgentStreamEvent(ThreadRunStepCompletedValue); - /// Event sent when a run step fails. The data of this event is of type RunStep. - public static AgentStreamEvent ThreadRunStepFailed { get; } = new AgentStreamEvent(ThreadRunStepFailedValue); - /// Event sent when a run step is cancelled. The data of this event is of type RunStep. - public static AgentStreamEvent ThreadRunStepCancelled { get; } = new AgentStreamEvent(ThreadRunStepCancelledValue); - /// Event sent when a run step is expired. The data of this event is of type RunStep. - public static AgentStreamEvent ThreadRunStepExpired { get; } = new AgentStreamEvent(ThreadRunStepExpiredValue); - /// Event sent when a new message is created. The data of this event is of type ThreadMessage. - public static AgentStreamEvent ThreadMessageCreated { get; } = new AgentStreamEvent(ThreadMessageCreatedValue); - /// Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage. - public static AgentStreamEvent ThreadMessageInProgress { get; } = new AgentStreamEvent(ThreadMessageInProgressValue); - /// Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk. - public static AgentStreamEvent ThreadMessageDelta { get; } = new AgentStreamEvent(ThreadMessageDeltaValue); - /// Event sent when a message is completed. The data of this event is of type ThreadMessage. - public static AgentStreamEvent ThreadMessageCompleted { get; } = new AgentStreamEvent(ThreadMessageCompletedValue); - /// Event sent before a message is completed. The data of this event is of type ThreadMessage. - public static AgentStreamEvent ThreadMessageIncomplete { get; } = new AgentStreamEvent(ThreadMessageIncompleteValue); - /// Event sent when an error occurs, such as an internal server error or a timeout. - public static AgentStreamEvent Error { get; } = new AgentStreamEvent(ErrorValue); - /// Event sent when the stream is done. - public static AgentStreamEvent Done { get; } = new AgentStreamEvent(DoneValue); - /// Determines if two values are the same. - public static bool operator ==(AgentStreamEvent left, AgentStreamEvent right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(AgentStreamEvent left, AgentStreamEvent right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AgentStreamEvent(string value) => new AgentStreamEvent(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AgentStreamEvent other && Equals(other); - /// - public bool Equals(AgentStreamEvent 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/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.cs deleted file mode 100644 index 3d11c01c11fd..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Information about a single thread associated with an agent. - public partial class AgentThread - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// The Unix timestamp, in seconds, representing when this object was created. - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type - /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list - /// of vector store IDs. - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// is null. - internal AgentThread(string id, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - CreatedAt = createdAt; - ToolResources = toolResources; - Metadata = metadata; - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always 'thread'. - /// The Unix timestamp, in seconds, representing when this object was created. - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type - /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list - /// of vector store IDs. - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal AgentThread(string id, string @object, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - ToolResources = toolResources; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AgentThread() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - - /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type - /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list - /// of vector store IDs. - /// - public ToolResources ToolResources { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadCreationOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadCreationOptions.Serialization.cs deleted file mode 100644 index 7dc65d3d81df..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadCreationOptions.Serialization.cs +++ /dev/null @@ -1,215 +0,0 @@ -// 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 AgentThreadCreationOptions : 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(AgentThreadCreationOptions)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(Messages)) - { - writer.WritePropertyName("messages"u8); - writer.WriteStartArray(); - foreach (var item in Messages) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(ToolResources)) - { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - AgentThreadCreationOptions 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(AgentThreadCreationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAgentThreadCreationOptions(document.RootElement, options); - } - - internal static AgentThreadCreationOptions DeserializeAgentThreadCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList messages = default; - ToolResources toolResources = default; - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("messages"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ThreadMessageOptions.DeserializeThreadMessageOptions(item, options)); - } - messages = array; - continue; - } - if (property.NameEquals("tool_resources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = ToolResources.DeserializeToolResources(property.Value, options); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AgentThreadCreationOptions(messages ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AgentThreadCreationOptions)} does not support writing '{options.Format}' format."); - } - } - - AgentThreadCreationOptions 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 DeserializeAgentThreadCreationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AgentThreadCreationOptions)} 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 AgentThreadCreationOptions FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentThreadCreationOptions(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/AgentThreadCreationOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadCreationOptions.cs deleted file mode 100644 index 384b24441047..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadCreationOptions.cs +++ /dev/null @@ -1,83 +0,0 @@ -// 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 details used to create a new agent thread. - public partial class AgentThreadCreationOptions - { - /// - /// 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 . - public AgentThreadCreationOptions() - { - Messages = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The initial messages to associate with the new thread. - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs. - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal AgentThreadCreationOptions(IList messages, ToolResources toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData) - { - Messages = messages; - ToolResources = toolResources; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The initial messages to associate with the new thread. - public IList Messages { get; } - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs. - /// - public ToolResources ToolResources { get; set; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IDictionary Metadata { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormatMode.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormatMode.cs deleted file mode 100644 index 283e0295f37b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormatMode.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Represents the mode in which the model will handle the return format of a tool call. - public readonly partial struct AgentsApiResponseFormatMode : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AgentsApiResponseFormatMode(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string NoneValue = "none"; - - /// Default value. Let the model handle the return format. - public static AgentsApiResponseFormatMode Auto { get; } = new AgentsApiResponseFormatMode(AutoValue); - /// Setting the value to `none`, will result in a 400 Bad request. - public static AgentsApiResponseFormatMode None { get; } = new AgentsApiResponseFormatMode(NoneValue); - /// Determines if two values are the same. - public static bool operator ==(AgentsApiResponseFormatMode left, AgentsApiResponseFormatMode right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(AgentsApiResponseFormatMode left, AgentsApiResponseFormatMode right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AgentsApiResponseFormatMode(string value) => new AgentsApiResponseFormatMode(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AgentsApiResponseFormatMode other && Equals(other); - /// - public bool Equals(AgentsApiResponseFormatMode 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/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiToolChoiceOptionMode.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiToolChoiceOptionMode.cs deleted file mode 100644 index 7f7f9ab114ea..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiToolChoiceOptionMode.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Specifies how the tool choice will be used. - public readonly partial struct AgentsApiToolChoiceOptionMode : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AgentsApiToolChoiceOptionMode(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string NoneValue = "none"; - private const string AutoValue = "auto"; - - /// The model will not call a function and instead generates a message. - public static AgentsApiToolChoiceOptionMode None { get; } = new AgentsApiToolChoiceOptionMode(NoneValue); - /// The model can pick between generating a message or calling a function. - public static AgentsApiToolChoiceOptionMode Auto { get; } = new AgentsApiToolChoiceOptionMode(AutoValue); - /// Determines if two values are the same. - public static bool operator ==(AgentsApiToolChoiceOptionMode left, AgentsApiToolChoiceOptionMode right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(AgentsApiToolChoiceOptionMode left, AgentsApiToolChoiceOptionMode right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AgentsApiToolChoiceOptionMode(string value) => new AgentsApiToolChoiceOptionMode(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AgentsApiToolChoiceOptionMode other && Equals(other); - /// - public bool Equals(AgentsApiToolChoiceOptionMode 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/sdk/ai/Azure.AI.Projects/src/Generated/AgentsClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsClient.cs deleted file mode 100644 index 0ea97447ed7d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsClient.cs +++ /dev/null @@ -1,6070 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.AI.Projects -{ - // Data plane generated sub-client. - /// The Agents sub-client. - public partial class AgentsClient - { - private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com/.default" }; - private readonly TokenCredential _tokenCredential; - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _subscriptionId; - private readonly string _resourceGroupName; - private readonly string _projectName; - private readonly string _apiVersion; - - /// The ClientDiagnostics is used to provide tracing support for the client library. - internal ClientDiagnostics ClientDiagnostics { get; } - - /// The HTTP pipeline for sending and receiving REST requests and responses. - public virtual HttpPipeline Pipeline => _pipeline; - - /// Initializes a new instance of AgentsClient for mocking. - protected AgentsClient() - { - } - - /// Initializes a new instance of AgentsClient. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The token credential to copy. - /// The Azure AI Foundry project endpoint, in the form `https://<azure-region>.api.azureml.ms` or `https://<private-link-guid>.<azure-region>.api.azureml.ms`, where <azure-region> is the Azure region where the project is deployed (e.g. westus) and <private-link-guid> is the GUID of the Enterprise private link. - /// The Azure subscription ID. - /// The name of the Azure Resource Group. - /// The Azure AI Foundry project name. - /// The API version to use for this operation. - internal AgentsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string subscriptionId, string resourceGroupName, string projectName, string apiVersion) - { - ClientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - _tokenCredential = tokenCredential; - _endpoint = endpoint; - _subscriptionId = subscriptionId; - _resourceGroupName = resourceGroupName; - _projectName = projectName; - _apiVersion = apiVersion; - } - - /// Creates a new agent. - /// The ID of the model to use. - /// The name of the new agent. - /// The description of the new agent. - /// The system instructions for the new agent to use. - /// The collection of tools to enable for the new agent. - /// - /// 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` - /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// The response format of the tool calls used by this agent. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - public virtual async Task> CreateAgentAsync(string model, string name = null, string description = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(model, nameof(model)); - - CreateAgentRequest createAgentRequest = new CreateAgentRequest( - model, - name, - description, - instructions, - tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - toolResources, - temperature, - topP, - responseFormat, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateAgentAsync(createAgentRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(Agent.FromResponse(response), response); - } - - /// Creates a new agent. - /// The ID of the model to use. - /// The name of the new agent. - /// The description of the new agent. - /// The system instructions for the new agent to use. - /// The collection of tools to enable for the new agent. - /// - /// 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` - /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// The response format of the tool calls used by this agent. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - public virtual Response CreateAgent(string model, string name = null, string description = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(model, nameof(model)); - - CreateAgentRequest createAgentRequest = new CreateAgentRequest( - model, - name, - description, - instructions, - tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - toolResources, - temperature, - topP, - responseFormat, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateAgent(createAgentRequest.ToRequestContent(), context); - return Response.FromValue(Agent.FromResponse(response), response); - } - - /// - /// [Protocol Method] Creates a new agent. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CreateAgentAsync(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateAgent"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateAgentRequest(content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Creates a new agent. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CreateAgent(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateAgent"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateAgentRequest(content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a list of agents that were previously created. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - internal virtual async Task> InternalGetAgentsAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetAgentsAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfAgent.FromResponse(response), response); - } - - /// Gets a list of agents that were previously created. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - internal virtual Response InternalGetAgents(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetAgents(limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfAgent.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets a list of agents that were previously created. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalGetAgentsAsync(int? limit, string order, string after, string before, RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetAgents"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetAgentsRequest(limit, order, after, before, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets a list of agents that were previously created. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalGetAgents(int? limit, string order, string after, string before, RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetAgents"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetAgentsRequest(limit, order, after, before, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Retrieves an existing agent. - /// Identifier of the agent. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetAgentAsync(string assistantId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetAgentAsync(assistantId, context).ConfigureAwait(false); - return Response.FromValue(Agent.FromResponse(response), response); - } - - /// Retrieves an existing agent. - /// Identifier of the agent. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetAgent(string assistantId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetAgent(assistantId, context); - return Response.FromValue(Agent.FromResponse(response), response); - } - - /// - /// [Protocol Method] Retrieves an existing agent. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the agent. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAgentAsync(string assistantId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetAgent"); - scope.Start(); - try - { - using HttpMessage message = CreateGetAgentRequest(assistantId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Retrieves an existing agent. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the agent. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetAgent(string assistantId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetAgent"); - scope.Start(); - try - { - using HttpMessage message = CreateGetAgentRequest(assistantId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Modifies an existing agent. - /// The ID of the agent to modify. - /// The ID of the model to use. - /// The modified name for the agent to use. - /// The modified description for the agent to use. - /// The modified system instructions for the new agent to use. - /// The modified collection of tools to enable for the agent. - /// - /// 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` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// The response format of the tool calls used by this agent. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> UpdateAgentAsync(string assistantId, string model = null, string name = null, string description = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - UpdateAgentRequest updateAgentRequest = new UpdateAgentRequest( - model, - name, - description, - instructions, - tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - toolResources, - temperature, - topP, - responseFormat, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await UpdateAgentAsync(assistantId, updateAgentRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(Agent.FromResponse(response), response); - } - - /// Modifies an existing agent. - /// The ID of the agent to modify. - /// The ID of the model to use. - /// The modified name for the agent to use. - /// The modified description for the agent to use. - /// The modified system instructions for the new agent to use. - /// The modified collection of tools to enable for the agent. - /// - /// 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` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// The response format of the tool calls used by this agent. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response UpdateAgent(string assistantId, string model = null, string name = null, string description = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - UpdateAgentRequest updateAgentRequest = new UpdateAgentRequest( - model, - name, - description, - instructions, - tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - toolResources, - temperature, - topP, - responseFormat, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = UpdateAgent(assistantId, updateAgentRequest.ToRequestContent(), context); - return Response.FromValue(Agent.FromResponse(response), response); - } - - /// - /// [Protocol Method] Modifies an existing agent. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the agent to modify. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task UpdateAgentAsync(string assistantId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UpdateAgent"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateAgentRequest(assistantId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Modifies an existing agent. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the agent to modify. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response UpdateAgent(string assistantId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UpdateAgent"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateAgentRequest(assistantId, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Deletes an agent. - /// Identifier of the agent. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalDeleteAgentAsync(string assistantId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalDeleteAgentAsync(assistantId, context).ConfigureAwait(false); - return Response.FromValue(InternalAgentDeletionStatus.FromResponse(response), response); - } - - /// Deletes an agent. - /// Identifier of the agent. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalDeleteAgent(string assistantId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalDeleteAgent(assistantId, context); - return Response.FromValue(InternalAgentDeletionStatus.FromResponse(response), response); - } - - /// - /// [Protocol Method] Deletes an agent. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the agent. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalDeleteAgentAsync(string assistantId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalDeleteAgent"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalDeleteAgentRequest(assistantId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Deletes an agent. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the agent. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalDeleteAgent(string assistantId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalDeleteAgent"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalDeleteAgentRequest(assistantId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Creates a new thread. Threads contain messages and can be run by agents. - /// The initial messages to associate with the new thread. - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs. - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - public virtual async Task> CreateThreadAsync(IEnumerable messages = null, ToolResources toolResources = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - CreateThreadRequest createThreadRequest = new CreateThreadRequest(messages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateThreadAsync(createThreadRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(AgentThread.FromResponse(response), response); - } - - /// Creates a new thread. Threads contain messages and can be run by agents. - /// The initial messages to associate with the new thread. - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs. - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - public virtual Response CreateThread(IEnumerable messages = null, ToolResources toolResources = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - CreateThreadRequest createThreadRequest = new CreateThreadRequest(messages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateThread(createThreadRequest.ToRequestContent(), context); - return Response.FromValue(AgentThread.FromResponse(response), response); - } - - /// - /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by agents. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CreateThreadAsync(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateThread"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateThreadRequest(content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by agents. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CreateThread(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateThread"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateThreadRequest(content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets information about an existing thread. - /// Identifier of the thread. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetThreadAsync(string threadId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetThreadAsync(threadId, context).ConfigureAwait(false); - return Response.FromValue(AgentThread.FromResponse(response), response); - } - - /// Gets information about an existing thread. - /// Identifier of the thread. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetThread(string threadId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetThread(threadId, context); - return Response.FromValue(AgentThread.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets information about an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetThreadAsync(string threadId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetThread"); - scope.Start(); - try - { - using HttpMessage message = CreateGetThreadRequest(threadId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets information about an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetThread(string threadId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetThread"); - scope.Start(); - try - { - using HttpMessage message = CreateGetThreadRequest(threadId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Modifies an existing thread. - /// The ID of the thread to modify. - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> UpdateThreadAsync(string threadId, ToolResources toolResources = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest(toolResources, metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await UpdateThreadAsync(threadId, updateThreadRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(AgentThread.FromResponse(response), response); - } - - /// Modifies an existing thread. - /// The ID of the thread to modify. - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response UpdateThread(string threadId, ToolResources toolResources = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest(toolResources, metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = UpdateThread(threadId, updateThreadRequest.ToRequestContent(), context); - return Response.FromValue(AgentThread.FromResponse(response), response); - } - - /// - /// [Protocol Method] Modifies an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the thread to modify. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task UpdateThreadAsync(string threadId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UpdateThread"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Modifies an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the thread to modify. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response UpdateThread(string threadId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UpdateThread"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Deletes an existing thread. - /// Identifier of the thread. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalDeleteThreadAsync(string threadId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalDeleteThreadAsync(threadId, context).ConfigureAwait(false); - return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response); - } - - /// Deletes an existing thread. - /// Identifier of the thread. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalDeleteThread(string threadId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalDeleteThread(threadId, context); - return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response); - } - - /// - /// [Protocol Method] Deletes an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalDeleteThreadAsync(string threadId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalDeleteThread"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Deletes an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalDeleteThread(string threadId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalDeleteThread"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a list of threads that were previously created. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - internal virtual async Task> InternalGetThreadsAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetThreadsAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(OpenAIPageableListOfAgentThread.FromResponse(response), response); - } - - /// Gets a list of threads that were previously created. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - internal virtual Response InternalGetThreads(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetThreads(limit, order?.ToString(), after, before, context); - return Response.FromValue(OpenAIPageableListOfAgentThread.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets a list of threads that were previously created. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalGetThreadsAsync(int? limit, string order, string after, string before, RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetThreads"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetThreadsRequest(limit, order, after, before, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets a list of threads that were previously created. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalGetThreads(int? limit, string order, string after, string before, RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetThreads"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetThreadsRequest(limit, order, after, before, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Creates a new message on a specified thread. - /// Identifier of the thread. - /// - /// The role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). - /// - /// A list of files attached to the message, and the tools they should be added to. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> CreateMessageAsync(string threadId, MessageRole role, BinaryData content, IEnumerable attachments = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); - - CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content, attachments?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateMessageAsync(threadId, createMessageRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(ThreadMessage.FromResponse(response), response); - } - - /// Creates a new message on a specified thread. - /// Identifier of the thread. - /// - /// The role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). - /// - /// A list of files attached to the message, and the tools they should be added to. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response CreateMessage(string threadId, MessageRole role, BinaryData content, IEnumerable attachments = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); - - CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content, attachments?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateMessage(threadId, createMessageRequest.ToRequestContent(), context); - return Response.FromValue(ThreadMessage.FromResponse(response), response); - } - - /// - /// [Protocol Method] Creates a new message on a specified thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CreateMessageAsync(string threadId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateMessage"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateMessageRequest(threadId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Creates a new message on a specified thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CreateMessage(string threadId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateMessage"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateMessageRequest(threadId, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a list of messages that exist on a thread. - /// Identifier of the thread. - /// Filter messages by the run ID that generated them. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalGetMessagesAsync(string threadId, string runId = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetMessagesAsync(threadId, runId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response); - } - - /// Gets a list of messages that exist on a thread. - /// Identifier of the thread. - /// Filter messages by the run ID that generated them. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalGetMessages(string threadId, string runId = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetMessages(threadId, runId, limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets a list of messages that exist on a thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Filter messages by the run ID that generated them. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalGetMessagesAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetMessages"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetMessagesRequest(threadId, runId, limit, order, after, before, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets a list of messages that exist on a thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Filter messages by the run ID that generated them. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalGetMessages(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetMessages"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetMessagesRequest(threadId, runId, limit, order, after, before, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets an existing message from an existing thread. - /// Identifier of the thread. - /// Identifier of the message. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> GetMessageAsync(string threadId, string messageId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetMessageAsync(threadId, messageId, context).ConfigureAwait(false); - return Response.FromValue(ThreadMessage.FromResponse(response), response); - } - - /// Gets an existing message from an existing thread. - /// Identifier of the thread. - /// Identifier of the message. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response GetMessage(string threadId, string messageId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetMessage(threadId, messageId, context); - return Response.FromValue(ThreadMessage.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets an existing message from an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the message. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetMessageAsync(string threadId, string messageId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetMessage"); - scope.Start(); - try - { - using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets an existing message from an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the message. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetMessage(string threadId, string messageId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetMessage"); - scope.Start(); - try - { - using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Modifies an existing message on an existing thread. - /// Identifier of the thread. - /// Identifier of the message. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> UpdateMessageAsync(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - - UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await UpdateMessageAsync(threadId, messageId, updateMessageRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(ThreadMessage.FromResponse(response), response); - } - - /// Modifies an existing message on an existing thread. - /// Identifier of the thread. - /// Identifier of the message. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response UpdateMessage(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - - UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = UpdateMessage(threadId, messageId, updateMessageRequest.ToRequestContent(), context); - return Response.FromValue(ThreadMessage.FromResponse(response), response); - } - - /// - /// [Protocol Method] Modifies an existing message on an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the message. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task UpdateMessageAsync(string threadId, string messageId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UpdateMessage"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Modifies an existing message on an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the message. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response UpdateMessage(string threadId, string messageId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UpdateMessage"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Creates a new run for an agent thread. - /// Identifier of the thread. - /// The ID of the agent that should run the thread. - /// The overridden model name that the agent should use to run the thread. - /// The overridden system instructions that the agent should use to run the thread. - /// - /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior - /// on a per-run basis without overriding other instructions. - /// - /// Adds additional messages to the thread before creating the run. - /// The overridden list of enabled tools that the agent should use to run the thread. - /// - /// If `true`, returns a stream of events that happen during the Run as server-sent events, - /// terminating when the Run enters a terminal state with a `data: [DONE]` message. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - /// more random, while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model - /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - /// comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// - /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - /// the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// - /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort - /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of - /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// The strategy to use for dropping messages as the context windows moves forward. - /// Controls whether or not and which tool is called by the model. - /// Specifies the format that the model must output. - /// If `true` functions will run in parallel during tool use. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> CreateRunAsync(string threadId, string assistantId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, IEnumerable include = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(assistantId, nameof(assistantId)); - - CreateRunRequest createRunRequest = new CreateRunRequest( - assistantId, - overrideModelName, - overrideInstructions, - additionalInstructions, - additionalMessages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - stream, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - responseFormat, - parallelToolCalls, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateRunAsync(threadId, createRunRequest.ToRequestContent(), include, context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// Creates a new run for an agent thread. - /// Identifier of the thread. - /// The ID of the agent that should run the thread. - /// The overridden model name that the agent should use to run the thread. - /// The overridden system instructions that the agent should use to run the thread. - /// - /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior - /// on a per-run basis without overriding other instructions. - /// - /// Adds additional messages to the thread before creating the run. - /// The overridden list of enabled tools that the agent should use to run the thread. - /// - /// If `true`, returns a stream of events that happen during the Run as server-sent events, - /// terminating when the Run enters a terminal state with a `data: [DONE]` message. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - /// more random, while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model - /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - /// comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// - /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - /// the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// - /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort - /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of - /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// The strategy to use for dropping messages as the context windows moves forward. - /// Controls whether or not and which tool is called by the model. - /// Specifies the format that the model must output. - /// If `true` functions will run in parallel during tool use. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response CreateRun(string threadId, string assistantId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, IEnumerable include = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(assistantId, nameof(assistantId)); - - CreateRunRequest createRunRequest = new CreateRunRequest( - assistantId, - overrideModelName, - overrideInstructions, - additionalInstructions, - additionalMessages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - stream, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - responseFormat, - parallelToolCalls, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateRun(threadId, createRunRequest.ToRequestContent(), include, context); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// - /// [Protocol Method] Creates a new run for an agent thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// The content to send as the body of the request. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CreateRunAsync(string threadId, RequestContent content, IEnumerable include = null, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateRun"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateRunRequest(threadId, content, include, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Creates a new run for an agent thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// The content to send as the body of the request. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CreateRun(string threadId, RequestContent content, IEnumerable include = null, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateRun"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateRunRequest(threadId, content, include, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a list of runs for a specified thread. - /// Identifier of the thread. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalGetRunsAsync(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetRunsAsync(threadId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfThreadRun.FromResponse(response), response); - } - - /// Gets a list of runs for a specified thread. - /// Identifier of the thread. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalGetRuns(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetRuns(threadId, limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfThreadRun.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets a list of runs for a specified thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalGetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetRuns"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets a list of runs for a specified thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalGetRuns(string threadId, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetRuns"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets an existing run from an existing thread. - /// Identifier of the thread. - /// Identifier of the run. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> GetRunAsync(string threadId, string runId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetRunAsync(threadId, runId, context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// Gets an existing run from an existing thread. - /// Identifier of the thread. - /// Identifier of the run. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response GetRun(string threadId, string runId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetRun(threadId, runId, context); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets an existing run from an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetRunAsync(string threadId, string runId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetRun"); - scope.Start(); - try - { - using HttpMessage message = CreateGetRunRequest(threadId, runId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets an existing run from an existing thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetRun(string threadId, string runId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetRun"); - scope.Start(); - try - { - using HttpMessage message = CreateGetRunRequest(threadId, runId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Modifies an existing thread run. - /// Identifier of the thread. - /// Identifier of the run. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> UpdateRunAsync(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await UpdateRunAsync(threadId, runId, updateRunRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// Modifies an existing thread run. - /// Identifier of the thread. - /// Identifier of the run. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response UpdateRun(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = UpdateRun(threadId, runId, updateRunRequest.ToRequestContent(), context); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// - /// [Protocol Method] Modifies an existing thread run. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task UpdateRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UpdateRun"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Modifies an existing thread run. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response UpdateRun(string threadId, string runId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UpdateRun"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Cancels a run of an in progress thread. - /// Identifier of the thread. - /// Identifier of the run. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> CancelRunAsync(string threadId, string runId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CancelRunAsync(threadId, runId, context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// Cancels a run of an in progress thread. - /// Identifier of the thread. - /// Identifier of the run. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response CancelRun(string threadId, string runId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CancelRun(threadId, runId, context); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// - /// [Protocol Method] Cancels a run of an in progress thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CancelRunAsync(string threadId, string runId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CancelRun"); - scope.Start(); - try - { - using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Cancels a run of an in progress thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CancelRun(string threadId, string runId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CancelRun"); - scope.Start(); - try - { - using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Creates a new agent thread and immediately starts a run using that new thread. - /// The ID of the agent for which the thread should be created. - /// The details used to create the new thread. If no thread is provided, an empty one will be created. - /// The overridden model that the agent should use to run the thread. - /// The overridden system instructions the agent should use to run the thread. - /// The overridden list of enabled tools the agent should use to run the thread. - /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. - /// - /// If `true`, returns a stream of events that happen during the Run as server-sent events, - /// terminating when the Run enters a terminal state with a `data: [DONE]` message. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - /// more random, while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model - /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - /// comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// - /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - /// the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// - /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens - /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// The strategy to use for dropping messages as the context windows moves forward. - /// Controls whether or not and which tool is called by the model. - /// Specifies the format that the model must output. - /// If `true` functions will run in parallel during tool use. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - public virtual async Task> CreateThreadAndRunAsync(string assistantId, AgentThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, UpdateToolResourcesOptions toolResources = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(assistantId, nameof(assistantId)); - - CreateThreadAndRunRequest createThreadAndRunRequest = new CreateThreadAndRunRequest( - assistantId, - thread, - overrideModelName, - overrideInstructions, - overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - toolResources, - stream, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - responseFormat, - parallelToolCalls, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateThreadAndRunAsync(createThreadAndRunRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// Creates a new agent thread and immediately starts a run using that new thread. - /// The ID of the agent for which the thread should be created. - /// The details used to create the new thread. If no thread is provided, an empty one will be created. - /// The overridden model that the agent should use to run the thread. - /// The overridden system instructions the agent should use to run the thread. - /// The overridden list of enabled tools the agent should use to run the thread. - /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. - /// - /// If `true`, returns a stream of events that happen during the Run as server-sent events, - /// terminating when the Run enters a terminal state with a `data: [DONE]` message. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - /// more random, while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model - /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - /// comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// - /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - /// the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// - /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens - /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// The strategy to use for dropping messages as the context windows moves forward. - /// Controls whether or not and which tool is called by the model. - /// Specifies the format that the model must output. - /// If `true` functions will run in parallel during tool use. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - public virtual Response CreateThreadAndRun(string assistantId, AgentThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, UpdateToolResourcesOptions toolResources = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(assistantId, nameof(assistantId)); - - CreateThreadAndRunRequest createThreadAndRunRequest = new CreateThreadAndRunRequest( - assistantId, - thread, - overrideModelName, - overrideInstructions, - overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - toolResources, - stream, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - responseFormat, - parallelToolCalls, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateThreadAndRun(createThreadAndRunRequest.ToRequestContent(), context); - return Response.FromValue(ThreadRun.FromResponse(response), response); - } - - /// - /// [Protocol Method] Creates a new agent thread and immediately starts a run using that new thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CreateThreadAndRunAsync(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateThreadAndRun"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Creates a new agent thread and immediately starts a run using that new thread. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CreateThreadAndRun(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateThreadAndRun"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a single run step from a thread run. - /// Identifier of the thread. - /// Identifier of the run. - /// Identifier of the run step. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public virtual async Task> GetRunStepAsync(string threadId, string runId, string stepId, IEnumerable include = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetRunStepAsync(threadId, runId, stepId, include, context).ConfigureAwait(false); - return Response.FromValue(RunStep.FromResponse(response), response); - } - - /// Gets a single run step from a thread run. - /// Identifier of the thread. - /// Identifier of the run. - /// Identifier of the run step. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public virtual Response GetRunStep(string threadId, string runId, string stepId, IEnumerable include = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetRunStep(threadId, runId, stepId, include, context); - return Response.FromValue(RunStep.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets a single run step from a thread run. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// Identifier of the run step. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetRunStepAsync(string threadId, string runId, string stepId, IEnumerable include, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetRunStep"); - scope.Start(); - try - { - using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, include, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets a single run step from a thread run. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// Identifier of the run step. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetRunStep(string threadId, string runId, string stepId, IEnumerable include, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetRunStep"); - scope.Start(); - try - { - using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, include, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a list of run steps from a thread run. - /// Identifier of the thread. - /// Identifier of the run. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalGetRunStepsAsync(string threadId, string runId, IEnumerable include = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetRunStepsAsync(threadId, runId, include, limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfRunStep.FromResponse(response), response); - } - - /// Gets a list of run steps from a thread run. - /// Identifier of the thread. - /// Identifier of the run. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - internal virtual Response InternalGetRunSteps(string threadId, string runId, IEnumerable include = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetRunSteps(threadId, runId, include, limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfRunStep.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets a list of run steps from a thread run. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalGetRunStepsAsync(string threadId, string runId, IEnumerable include, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetRunSteps"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, include, limit, order, after, before, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets a list of run steps from a thread run. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the thread. - /// Identifier of the run. - /// - /// A list of additional fields to include in the response. - /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalGetRunSteps(string threadId, string runId, IEnumerable include, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalGetRunSteps"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, include, limit, order, after, before, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a list of previously uploaded files. - /// The purpose of the file. - /// The cancellation token to use. - internal virtual async Task> InternalListFilesAsync(AgentFilePurpose? purpose = null, CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalListFilesAsync(purpose?.ToString(), context).ConfigureAwait(false); - return Response.FromValue(InternalFileListResponse.FromResponse(response), response); - } - - /// Gets a list of previously uploaded files. - /// The purpose of the file. - /// The cancellation token to use. - internal virtual Response InternalListFiles(AgentFilePurpose? purpose = null, CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalListFiles(purpose?.ToString(), context); - return Response.FromValue(InternalFileListResponse.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets a list of previously uploaded files. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The purpose of the file. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output" | "batch" | "batch_output" | "vision". - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalListFilesAsync(string purpose, RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalListFiles"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalListFilesRequest(purpose, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets a list of previously uploaded files. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The purpose of the file. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output" | "batch" | "batch_output" | "vision". - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalListFiles(string purpose, RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalListFiles"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalListFilesRequest(purpose, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Uploads a file for use by other operations. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The name of the file to upload. Allowed values: "multipart/form-data". - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task UploadFileAsync(RequestContent content, string contentType, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UploadFile"); - scope.Start(); - try - { - using HttpMessage message = CreateUploadFileRequest(content, contentType, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Uploads a file for use by other operations. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The name of the file to upload. Allowed values: "multipart/form-data". - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response UploadFile(RequestContent content, string contentType, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.UploadFile"); - scope.Start(); - try - { - using HttpMessage message = CreateUploadFileRequest(content, contentType, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Delete a previously uploaded file. - /// The ID of the file to delete. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalDeleteFileAsync(string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalDeleteFileAsync(fileId, context).ConfigureAwait(false); - return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response); - } - - /// Delete a previously uploaded file. - /// The ID of the file to delete. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalDeleteFile(string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalDeleteFile(fileId, context); - return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response); - } - - /// - /// [Protocol Method] Delete a previously uploaded file. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the file to delete. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task InternalDeleteFileAsync(string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalDeleteFile"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Delete a previously uploaded file. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the file to delete. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response InternalDeleteFile(string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.InternalDeleteFile"); - scope.Start(); - try - { - using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Returns information about a specific file. Does not retrieve file content. - /// The ID of the file to retrieve. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetFileAsync(string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetFileAsync(fileId, context).ConfigureAwait(false); - return Response.FromValue(AgentFile.FromResponse(response), response); - } - - /// Returns information about a specific file. Does not retrieve file content. - /// The ID of the file to retrieve. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetFile(string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetFile(fileId, context); - return Response.FromValue(AgentFile.FromResponse(response), response); - } - - /// - /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the file to retrieve. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetFileAsync(string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetFile"); - scope.Start(); - try - { - using HttpMessage message = CreateGetFileRequest(fileId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the file to retrieve. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetFile(string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetFile"); - scope.Start(); - try - { - using HttpMessage message = CreateGetFileRequest(fileId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Retrieves the raw content of a specific file. - /// The ID of the file to retrieve. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetFileContentAsync(string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetFileContentAsync(fileId, context).ConfigureAwait(false); - return Response.FromValue(response.Content, response); - } - - /// Retrieves the raw content of a specific file. - /// The ID of the file to retrieve. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetFileContent(string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetFileContent(fileId, context); - return Response.FromValue(response.Content, response); - } - - /// - /// [Protocol Method] Retrieves the raw content of a specific file. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the file to retrieve. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetFileContentAsync(string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetFileContent"); - scope.Start(); - try - { - using HttpMessage message = CreateGetFileContentRequest(fileId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Retrieves the raw content of a specific file. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The ID of the file to retrieve. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetFileContent(string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetFileContent"); - scope.Start(); - try - { - using HttpMessage message = CreateGetFileContentRequest(fileId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Returns a list of vector stores. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - public virtual async Task> GetVectorStoresAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetVectorStoresAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(AgentPageableListOfVectorStore.FromResponse(response), response); - } - - /// Returns a list of vector stores. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - public virtual Response GetVectorStores(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetVectorStores(limit, order?.ToString(), after, before, context); - return Response.FromValue(AgentPageableListOfVectorStore.FromResponse(response), response); - } - - /// - /// [Protocol Method] Returns a list of vector stores. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetVectorStoresAsync(int? limit, string order, string after, string before, RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStores"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoresRequest(limit, order, after, before, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Returns a list of vector stores. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetVectorStores(int? limit, string order, string after, string before, RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStores"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoresRequest(limit, order, after, before, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Creates a vector store. - /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. - /// The name of the vector store. - /// The vector store configuration, used when vector store is created from Azure asset URIs. - /// Details on when this vector store expires. - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - public virtual async Task> CreateVectorStoreAsync(IEnumerable fileIds = null, string name = null, VectorStoreConfiguration storeConfiguration = null, VectorStoreExpirationPolicy expiresAfter = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - CreateVectorStoreRequest createVectorStoreRequest = new CreateVectorStoreRequest( - fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - name, - storeConfiguration, - expiresAfter, - chunkingStrategy, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateVectorStoreAsync(createVectorStoreRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(VectorStore.FromResponse(response), response); - } - - /// Creates a vector store. - /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. - /// The name of the vector store. - /// The vector store configuration, used when vector store is created from Azure asset URIs. - /// Details on when this vector store expires. - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - public virtual Response CreateVectorStore(IEnumerable fileIds = null, string name = null, VectorStoreConfiguration storeConfiguration = null, VectorStoreExpirationPolicy expiresAfter = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - CreateVectorStoreRequest createVectorStoreRequest = new CreateVectorStoreRequest( - fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), - name, - storeConfiguration, - expiresAfter, - chunkingStrategy, - metadata ?? new ChangeTrackingDictionary(), - null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateVectorStore(createVectorStoreRequest.ToRequestContent(), context); - return Response.FromValue(VectorStore.FromResponse(response), response); - } - - /// - /// [Protocol Method] Creates a vector store. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CreateVectorStoreAsync(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateVectorStore"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateVectorStoreRequest(content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Creates a vector store. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CreateVectorStore(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateVectorStore"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateVectorStoreRequest(content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Returns the vector store object matching the specified ID. - /// Identifier of the vector store. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetVectorStoreAsync(string vectorStoreId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetVectorStoreAsync(vectorStoreId, context).ConfigureAwait(false); - return Response.FromValue(VectorStore.FromResponse(response), response); - } - - /// Returns the vector store object matching the specified ID. - /// Identifier of the vector store. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetVectorStore(string vectorStoreId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetVectorStore(vectorStoreId, context); - return Response.FromValue(VectorStore.FromResponse(response), response); - } - - /// - /// [Protocol Method] Returns the vector store object matching the specified ID. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetVectorStoreAsync(string vectorStoreId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStore"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreRequest(vectorStoreId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Returns the vector store object matching the specified ID. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetVectorStore(string vectorStoreId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStore"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreRequest(vectorStoreId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// The ID of the vector store to modify. - /// Identifier of the vector store. - /// The name of the vector store. - /// Details on when this vector store expires. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> ModifyVectorStoreAsync(string vectorStoreId, string name = null, VectorStoreExpirationPolicy expiresAfter = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - ModifyVectorStoreRequest modifyVectorStoreRequest = new ModifyVectorStoreRequest(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await ModifyVectorStoreAsync(vectorStoreId, modifyVectorStoreRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(VectorStore.FromResponse(response), response); - } - - /// The ID of the vector store to modify. - /// Identifier of the vector store. - /// The name of the vector store. - /// Details on when this vector store expires. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response ModifyVectorStore(string vectorStoreId, string name = null, VectorStoreExpirationPolicy expiresAfter = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - ModifyVectorStoreRequest modifyVectorStoreRequest = new ModifyVectorStoreRequest(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = ModifyVectorStore(vectorStoreId, modifyVectorStoreRequest.ToRequestContent(), context); - return Response.FromValue(VectorStore.FromResponse(response), response); - } - - /// - /// [Protocol Method] The ID of the vector store to modify. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task ModifyVectorStoreAsync(string vectorStoreId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.ModifyVectorStore"); - scope.Start(); - try - { - using HttpMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] The ID of the vector store to modify. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response ModifyVectorStore(string vectorStoreId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.ModifyVectorStore"); - scope.Start(); - try - { - using HttpMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Deletes the vector store object matching the specified ID. - /// Identifier of the vector store. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> DeleteVectorStoreAsync(string vectorStoreId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await DeleteVectorStoreAsync(vectorStoreId, context).ConfigureAwait(false); - return Response.FromValue(VectorStoreDeletionStatus.FromResponse(response), response); - } - - /// Deletes the vector store object matching the specified ID. - /// Identifier of the vector store. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response DeleteVectorStore(string vectorStoreId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = DeleteVectorStore(vectorStoreId, context); - return Response.FromValue(VectorStoreDeletionStatus.FromResponse(response), response); - } - - /// - /// [Protocol Method] Deletes the vector store object matching the specified ID. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task DeleteVectorStoreAsync(string vectorStoreId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.DeleteVectorStore"); - scope.Start(); - try - { - using HttpMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Deletes the vector store object matching the specified ID. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response DeleteVectorStore(string vectorStoreId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.DeleteVectorStore"); - scope.Start(); - try - { - using HttpMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Returns a list of vector store files. - /// Identifier of the vector store. - /// Filter by file status. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetVectorStoreFilesAsync(string vectorStoreId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetVectorStoreFilesAsync(vectorStoreId, filter?.ToString(), limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(AgentPageableListOfVectorStoreFile.FromResponse(response), response); - } - - /// Returns a list of vector store files. - /// Identifier of the vector store. - /// Filter by file status. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetVectorStoreFiles(string vectorStoreId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetVectorStoreFiles(vectorStoreId, filter?.ToString(), limit, order?.ToString(), after, before, context); - return Response.FromValue(AgentPageableListOfVectorStoreFile.FromResponse(response), response); - } - - /// - /// [Protocol Method] Returns a list of vector store files. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetVectorStoreFilesAsync(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStoreFiles"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, filter, limit, order, after, before, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Returns a list of vector store files. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetVectorStoreFiles(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStoreFiles"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, filter, limit, order, after, before, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Create a vector store file by attaching a file to a vector store. - /// Identifier of the vector store. - /// Identifier of the file. - /// Azure asset ID. - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> CreateVectorStoreFileAsync(string vectorStoreId, string fileId = null, VectorStoreDataSource dataSource = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - CreateVectorStoreFileRequest createVectorStoreFileRequest = new CreateVectorStoreFileRequest(fileId, dataSource, chunkingStrategy, null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateVectorStoreFileAsync(vectorStoreId, createVectorStoreFileRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(VectorStoreFile.FromResponse(response), response); - } - - /// Create a vector store file by attaching a file to a vector store. - /// Identifier of the vector store. - /// Identifier of the file. - /// Azure asset ID. - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response CreateVectorStoreFile(string vectorStoreId, string fileId = null, VectorStoreDataSource dataSource = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - CreateVectorStoreFileRequest createVectorStoreFileRequest = new CreateVectorStoreFileRequest(fileId, dataSource, chunkingStrategy, null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateVectorStoreFile(vectorStoreId, createVectorStoreFileRequest.ToRequestContent(), context); - return Response.FromValue(VectorStoreFile.FromResponse(response), response); - } - - /// - /// [Protocol Method] Create a vector store file by attaching a file to a vector store. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CreateVectorStoreFileAsync(string vectorStoreId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateVectorStoreFile"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Create a vector store file by attaching a file to a vector store. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CreateVectorStoreFile(string vectorStoreId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateVectorStoreFile"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Retrieves a vector store file. - /// Identifier of the vector store. - /// Identifier of the file. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> GetVectorStoreFileAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetVectorStoreFileAsync(vectorStoreId, fileId, context).ConfigureAwait(false); - return Response.FromValue(VectorStoreFile.FromResponse(response), response); - } - - /// Retrieves a vector store file. - /// Identifier of the vector store. - /// Identifier of the file. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response GetVectorStoreFile(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetVectorStoreFile(vectorStoreId, fileId, context); - return Response.FromValue(VectorStoreFile.FromResponse(response), response); - } - - /// - /// [Protocol Method] Retrieves a vector store file. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetVectorStoreFileAsync(string vectorStoreId, string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStoreFile"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreFileRequest(vectorStoreId, fileId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Retrieves a vector store file. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetVectorStoreFile(string vectorStoreId, string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStoreFile"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreFileRequest(vectorStoreId, fileId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. - /// To delete the file, use the delete file endpoint. - /// - /// Identifier of the vector store. - /// Identifier of the file. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> DeleteVectorStoreFileAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await DeleteVectorStoreFileAsync(vectorStoreId, fileId, context).ConfigureAwait(false); - return Response.FromValue(VectorStoreFileDeletionStatus.FromResponse(response), response); - } - - /// - /// Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. - /// To delete the file, use the delete file endpoint. - /// - /// Identifier of the vector store. - /// Identifier of the file. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response DeleteVectorStoreFile(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = DeleteVectorStoreFile(vectorStoreId, fileId, context); - return Response.FromValue(VectorStoreFileDeletionStatus.FromResponse(response), response); - } - - /// - /// [Protocol Method] Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. - /// To delete the file, use the delete file endpoint. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task DeleteVectorStoreFileAsync(string vectorStoreId, string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.DeleteVectorStoreFile"); - scope.Start(); - try - { - using HttpMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. - /// To delete the file, use the delete file endpoint. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response DeleteVectorStoreFile(string vectorStoreId, string fileId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.DeleteVectorStoreFile"); - scope.Start(); - try - { - using HttpMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Create a vector store file batch. - /// Identifier of the vector store. - /// List of file identifiers. - /// List of Azure assets. - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> CreateVectorStoreFileBatchAsync(string vectorStoreId, IEnumerable fileIds = null, IEnumerable dataSources = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequest = new CreateVectorStoreFileBatchRequest(fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), dataSources?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), chunkingStrategy, null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateVectorStoreFileBatchAsync(vectorStoreId, createVectorStoreFileBatchRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); - } - - /// Create a vector store file batch. - /// Identifier of the vector store. - /// List of file identifiers. - /// List of Azure assets. - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response CreateVectorStoreFileBatch(string vectorStoreId, IEnumerable fileIds = null, IEnumerable dataSources = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequest = new CreateVectorStoreFileBatchRequest(fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), dataSources?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), chunkingStrategy, null); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateVectorStoreFileBatch(vectorStoreId, createVectorStoreFileBatchRequest.ToRequestContent(), context); - return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); - } - - /// - /// [Protocol Method] Create a vector store file batch. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CreateVectorStoreFileBatchAsync(string vectorStoreId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateVectorStoreFileBatch"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Create a vector store file batch. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CreateVectorStoreFileBatch(string vectorStoreId, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CreateVectorStoreFileBatch"); - scope.Start(); - try - { - using HttpMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Retrieve a vector store file batch. - /// Identifier of the vector store. - /// Identifier of the file batch. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> GetVectorStoreFileBatchAsync(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetVectorStoreFileBatchAsync(vectorStoreId, batchId, context).ConfigureAwait(false); - return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); - } - - /// Retrieve a vector store file batch. - /// Identifier of the vector store. - /// Identifier of the file batch. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response GetVectorStoreFileBatch(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetVectorStoreFileBatch(vectorStoreId, batchId, context); - return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); - } - - /// - /// [Protocol Method] Retrieve a vector store file batch. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file batch. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetVectorStoreFileBatchAsync(string vectorStoreId, string batchId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStoreFileBatch"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreFileBatchRequest(vectorStoreId, batchId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Retrieve a vector store file batch. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file batch. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetVectorStoreFileBatch(string vectorStoreId, string batchId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStoreFileBatch"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreFileBatchRequest(vectorStoreId, batchId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. - /// Identifier of the vector store. - /// Identifier of the file batch. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> CancelVectorStoreFileBatchAsync(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CancelVectorStoreFileBatchAsync(vectorStoreId, batchId, context).ConfigureAwait(false); - return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); - } - - /// Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. - /// Identifier of the vector store. - /// Identifier of the file batch. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response CancelVectorStoreFileBatch(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = CancelVectorStoreFileBatch(vectorStoreId, batchId, context); - return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); - } - - /// - /// [Protocol Method] Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file batch. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task CancelVectorStoreFileBatchAsync(string vectorStoreId, string batchId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CancelVectorStoreFileBatch"); - scope.Start(); - try - { - using HttpMessage message = CreateCancelVectorStoreFileBatchRequest(vectorStoreId, batchId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file batch. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response CancelVectorStoreFileBatch(string vectorStoreId, string batchId, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.CancelVectorStoreFileBatch"); - scope.Start(); - try - { - using HttpMessage message = CreateCancelVectorStoreFileBatchRequest(vectorStoreId, batchId, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Returns a list of vector store files in a batch. - /// Identifier of the vector store. - /// Identifier of the file batch. - /// Filter by file status. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> GetVectorStoreFileBatchFilesAsync(string vectorStoreId, string batchId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetVectorStoreFileBatchFilesAsync(vectorStoreId, batchId, filter?.ToString(), limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(AgentPageableListOfVectorStoreFile.FromResponse(response), response); - } - - /// Returns a list of vector store files in a batch. - /// Identifier of the vector store. - /// Identifier of the file batch. - /// Filter by file status. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response GetVectorStoreFileBatchFiles(string vectorStoreId, string batchId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetVectorStoreFileBatchFiles(vectorStoreId, batchId, filter?.ToString(), limit, order?.ToString(), after, before, context); - return Response.FromValue(AgentPageableListOfVectorStoreFile.FromResponse(response), response); - } - - /// - /// [Protocol Method] Returns a list of vector store files in a batch. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file batch. - /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetVectorStoreFileBatchFilesAsync(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStoreFileBatchFiles"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreFileBatchFilesRequest(vectorStoreId, batchId, filter, limit, order, after, before, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Returns a list of vector store files in a batch. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Identifier of the vector store. - /// Identifier of the file batch. - /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetVectorStoreFileBatchFiles(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetVectorStoreFileBatchFiles"); - scope.Start(); - try - { - using HttpMessage message = CreateGetVectorStoreFileBatchFilesRequest(vectorStoreId, batchId, filter, limit, order, after, before, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - internal HttpMessage CreateCreateAgentRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/assistants", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateInternalGetAgentsRequest(int? limit, string order, string after, string before, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/assistants", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetAgentRequest(string assistantId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/assistants/", false); - uri.AppendPath(assistantId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateUpdateAgentRequest(string assistantId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/assistants/", false); - uri.AppendPath(assistantId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateInternalDeleteAgentRequest(string assistantId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/assistants/", false); - uri.AppendPath(assistantId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCreateThreadRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateGetThreadRequest(string threadId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateUpdateThreadRequest(string threadId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateInternalDeleteThreadRequest(string threadId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateInternalGetThreadsRequest(int? limit, string order, string after, string before, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCreateMessageRequest(string threadId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateInternalGetMessagesRequest(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (runId != null) - { - uri.AppendQuery("run_id", runId, true); - } - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetMessageRequest(string threadId, string messageId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages/", false); - uri.AppendPath(messageId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateUpdateMessageRequest(string threadId, string messageId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages/", false); - uri.AppendPath(messageId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateCreateRunRequest(string threadId, RequestContent content, IEnumerable include, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (include != null && !(include is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) - { - uri.AppendQueryDelimited("include[]", include, ",", true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateInternalGetRunsRequest(string threadId, int? limit, string order, string after, string before, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetRunRequest(string threadId, string runId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateUpdateRunRequest(string threadId, string runId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateSubmitToolOutputsToRunRequest(string threadId, string runId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendPath("/submit_tool_outputs", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateCancelRunRequest(string threadId, string runId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendPath("/cancel", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCreateThreadAndRunRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/runs", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateGetRunStepRequest(string threadId, string runId, string stepId, IEnumerable include, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendPath("/steps/", false); - uri.AppendPath(stepId, true); - uri.AppendQuery("api-version", _apiVersion, true); - if (include != null && !(include is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) - { - uri.AppendQueryDelimited("include[]", include, ",", true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateInternalGetRunStepsRequest(string threadId, string runId, IEnumerable include, int? limit, string order, string after, string before, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendPath("/steps", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (include != null && !(include is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) - { - uri.AppendQueryDelimited("include[]", include, ",", true); - } - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateInternalListFilesRequest(string purpose, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/files", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (purpose != null) - { - uri.AppendQuery("purpose", purpose, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateUploadFileRequest(RequestContent content, string contentType, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/files", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", contentType); - request.Content = content; - return message; - } - - internal HttpMessage CreateInternalDeleteFileRequest(string fileId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetFileRequest(string fileId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetFileContentRequest(string fileId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - uri.AppendPath("/content", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/octet-stream"); - return message; - } - - internal HttpMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCreateVectorStoreRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateModifyVectorStoreRequest(string vectorStoreId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateDeleteVectorStoreRequest(string vectorStoreId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetVectorStoreFilesRequest(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (filter != null) - { - uri.AppendQuery("filter", filter, true); - } - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCreateVectorStoreFileRequest(string vectorStoreId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateDeleteVectorStoreFileRequest(string vectorStoreId, string fileId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCreateVectorStoreFileBatchRequest(string vectorStoreId, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/cancel", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetVectorStoreFileBatchFilesRequest(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/files", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (filter != null) - { - uri.AppendQuery("filter", filter, true); - } - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - private static RequestContext DefaultRequestContext = new RequestContext(); - internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) - { - if (!cancellationToken.CanBeCanceled) - { - return DefaultRequestContext; - } - - return new RequestContext() { CancellationToken = cancellationToken }; - } - - private static ResponseClassifier _responseClassifier200; - private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoice.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoice.cs deleted file mode 100644 index eb7476192154..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoice.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Specifies a tool the model should use. Use to force the model to call a specific tool. - public partial class AgentsNamedToolChoice - { - /// - /// 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 type of tool. If type is `function`, the function name must be set. - public AgentsNamedToolChoice(AgentsNamedToolChoiceType type) - { - Type = type; - } - - /// Initializes a new instance of . - /// the type of tool. If type is `function`, the function name must be set. - /// The name of the function to call. - /// Keeps track of any properties unknown to the library. - internal AgentsNamedToolChoice(AgentsNamedToolChoiceType type, FunctionName function, IDictionary serializedAdditionalRawData) - { - Type = type; - Function = function; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AgentsNamedToolChoice() - { - } - - /// the type of tool. If type is `function`, the function name must be set. - public AgentsNamedToolChoiceType Type { get; set; } - /// The name of the function to call. - public FunctionName Function { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoiceType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoiceType.cs deleted file mode 100644 index 6ea93850ecd6..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoiceType.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Available tool types for agents named tools. - public readonly partial struct AgentsNamedToolChoiceType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AgentsNamedToolChoiceType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string FunctionValue = "function"; - private const string CodeInterpreterValue = "code_interpreter"; - private const string FileSearchValue = "file_search"; - private const string BingGroundingValue = "bing_grounding"; - 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"; - private const string ConnectedAgentValue = "connected_agent"; - - /// Tool type `function`. - public static AgentsNamedToolChoiceType Function { get; } = new AgentsNamedToolChoiceType(FunctionValue); - /// Tool type `code_interpreter`. - public static AgentsNamedToolChoiceType CodeInterpreter { get; } = new AgentsNamedToolChoiceType(CodeInterpreterValue); - /// Tool type `file_search`. - public static AgentsNamedToolChoiceType FileSearch { get; } = new AgentsNamedToolChoiceType(FileSearchValue); - /// Tool type `bing_grounding`. - public static AgentsNamedToolChoiceType BingGrounding { get; } = new AgentsNamedToolChoiceType(BingGroundingValue); - /// Tool type `fabric_dataagent`. - public static AgentsNamedToolChoiceType MicrosoftFabric { get; } = new AgentsNamedToolChoiceType(MicrosoftFabricValue); - /// Tool type `sharepoint_grounding`. - 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); - /// Tool type `connected_agent`. - public static AgentsNamedToolChoiceType ConnectedAgent { get; } = new AgentsNamedToolChoiceType(ConnectedAgentValue); - /// 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. - public static bool operator !=(AgentsNamedToolChoiceType left, AgentsNamedToolChoiceType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AgentsNamedToolChoiceType(string value) => new AgentsNamedToolChoiceType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AgentsNamedToolChoiceType other && Equals(other); - /// - public bool Equals(AgentsNamedToolChoiceType 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/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ApiKeyCredentials.Serialization.cs similarity index 58% rename from sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/ApiKeyCredentials.Serialization.cs index d1d2ca30898d..cf2a51356d10 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ApiKeyCredentials.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class CronTrigger : IUtf8JsonSerializable, IJsonModel + public partial class ApiKeyCredentials : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,30 +28,33 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(CronTrigger)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(ApiKeyCredentials)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("expression"u8); - writer.WriteStringValue(Expression); + if (options.Format != "W" && Optional.IsDefined(ApiKey)) + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(ApiKey); + } } - CronTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ApiKeyCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(CronTrigger)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(ApiKeyCredentials)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCronTrigger(document.RootElement, options); + return DeserializeApiKeyCredentials(document.RootElement, options); } - internal static CronTrigger DeserializeCronTrigger(JsonElement element, ModelReaderWriterOptions options = null) + internal static ApiKeyCredentials DeserializeApiKeyCredentials(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -59,20 +62,20 @@ internal static CronTrigger DeserializeCronTrigger(JsonElement element, ModelRea { return null; } - string expression = default; - string type = default; + string key = default; + CredentialType type = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("expression"u8)) + if (property.NameEquals("key"u8)) { - expression = property.Value.GetString(); + key = property.Value.GetString(); continue; } if (property.NameEquals("type"u8)) { - type = property.Value.GetString(); + type = new CredentialType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -81,46 +84,46 @@ internal static CronTrigger DeserializeCronTrigger(JsonElement element, ModelRea } } serializedAdditionalRawData = rawDataDictionary; - return new CronTrigger(type, serializedAdditionalRawData, expression); + return new ApiKeyCredentials(type, serializedAdditionalRawData, key); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(CronTrigger)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(ApiKeyCredentials)} does not support writing '{options.Format}' format."); } } - CronTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + ApiKeyCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCronTrigger(document.RootElement, options); + return DeserializeApiKeyCredentials(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(CronTrigger)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(ApiKeyCredentials)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new CronTrigger FromResponse(Response response) + internal static new ApiKeyCredentials FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCronTrigger(document.RootElement); + return DeserializeApiKeyCredentials(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ApiKeyCredentials.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ApiKeyCredentials.cs new file mode 100644 index 000000000000..46417329b5b7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ApiKeyCredentials.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// API Key Credential definition. + public partial class ApiKeyCredentials : BaseCredentials + { + /// Initializes a new instance of . + internal ApiKeyCredentials() + { + Type = CredentialType.ApiKey; + } + + /// Initializes a new instance of . + /// The type of credential used by the connection. + /// Keeps track of any properties unknown to the library. + /// API Key. + internal ApiKeyCredentials(CredentialType type, IDictionary serializedAdditionalRawData, string apiKey) : base(type, serializedAdditionalRawData) + { + ApiKey = apiKey; + } + + /// API Key. + public string ApiKey { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AppInsightsProperties.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AppInsightsProperties.Serialization.cs deleted file mode 100644 index 6437a738e27e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AppInsightsProperties.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 -{ - internal partial class AppInsightsProperties : 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(AppInsightsProperties)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("ConnectionString"u8); - writer.WriteStringValue(ConnectionString); - 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 - } - } - } - - AppInsightsProperties 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(AppInsightsProperties)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAppInsightsProperties(document.RootElement, options); - } - - internal static AppInsightsProperties DeserializeAppInsightsProperties(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string connectionString = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("ConnectionString"u8)) - { - connectionString = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AppInsightsProperties(connectionString, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AppInsightsProperties)} does not support writing '{options.Format}' format."); - } - } - - AppInsightsProperties 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 DeserializeAppInsightsProperties(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AppInsightsProperties)} 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 AppInsightsProperties FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAppInsightsProperties(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/ApplicationInsightsConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ApplicationInsightsConfiguration.Serialization.cs deleted file mode 100644 index 89ee3b59f9b7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ApplicationInsightsConfiguration.Serialization.cs +++ /dev/null @@ -1,170 +0,0 @@ -// 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 ApplicationInsightsConfiguration : 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(ApplicationInsightsConfiguration)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("resourceId"u8); - writer.WriteStringValue(ResourceId); - writer.WritePropertyName("query"u8); - writer.WriteStringValue(Query); - if (Optional.IsDefined(ServiceName)) - { - writer.WritePropertyName("serviceName"u8); - writer.WriteStringValue(ServiceName); - } - if (Optional.IsDefined(ConnectionString)) - { - writer.WritePropertyName("connectionString"u8); - writer.WriteStringValue(ConnectionString); - } - } - - ApplicationInsightsConfiguration 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(ApplicationInsightsConfiguration)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeApplicationInsightsConfiguration(document.RootElement, options); - } - - internal static ApplicationInsightsConfiguration DeserializeApplicationInsightsConfiguration(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string resourceId = default; - string query = default; - string serviceName = default; - string connectionString = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("resourceId"u8)) - { - resourceId = property.Value.GetString(); - continue; - } - if (property.NameEquals("query"u8)) - { - query = property.Value.GetString(); - continue; - } - if (property.NameEquals("serviceName"u8)) - { - serviceName = property.Value.GetString(); - continue; - } - if (property.NameEquals("connectionString"u8)) - { - connectionString = property.Value.GetString(); - 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 ApplicationInsightsConfiguration( - type, - serializedAdditionalRawData, - resourceId, - query, - serviceName, - connectionString); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ApplicationInsightsConfiguration)} does not support writing '{options.Format}' format."); - } - } - - ApplicationInsightsConfiguration 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 DeserializeApplicationInsightsConfiguration(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ApplicationInsightsConfiguration)} 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 ApplicationInsightsConfiguration FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeApplicationInsightsConfiguration(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/ApplicationInsightsConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ApplicationInsightsConfiguration.cs deleted file mode 100644 index 6658add0777d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ApplicationInsightsConfiguration.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Data Source for Application Insights. - public partial class ApplicationInsightsConfiguration : InputData - { - /// Initializes a new instance of . - /// LogAnalytic Workspace resourceID associated with ApplicationInsights. - /// Query to fetch the data. - /// or is null. - public ApplicationInsightsConfiguration(string resourceId, string query) - { - Argument.AssertNotNull(resourceId, nameof(resourceId)); - Argument.AssertNotNull(query, nameof(query)); - - Type = "app_insights"; - ResourceId = resourceId; - Query = query; - } - - /// Initializes a new instance of . - /// Type of the data. - /// Keeps track of any properties unknown to the library. - /// LogAnalytic Workspace resourceID associated with ApplicationInsights. - /// Query to fetch the data. - /// Service name. - /// Connection String to connect to ApplicationInsights. - internal ApplicationInsightsConfiguration(string type, IDictionary serializedAdditionalRawData, string resourceId, string query, string serviceName, string connectionString) : base(type, serializedAdditionalRawData) - { - ResourceId = resourceId; - Query = query; - ServiceName = serviceName; - ConnectionString = connectionString; - } - - /// Initializes a new instance of for deserialization. - internal ApplicationInsightsConfiguration() - { - } - - /// LogAnalytic Workspace resourceID associated with ApplicationInsights. - public string ResourceId { get; set; } - /// Query to fetch the data. - public string Query { get; set; } - /// Service name. - public string ServiceName { get; set; } - /// Connection String to connect to ApplicationInsights. - public string ConnectionString { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormat.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AssetCredentialResponse.Serialization.cs similarity index 65% rename from sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormat.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AssetCredentialResponse.Serialization.cs index 6fa71a037e34..453d9da80e7c 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsApiResponseFormat.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AssetCredentialResponse.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class AgentsApiResponseFormat : IUtf8JsonSerializable, IJsonModel + public partial class AssetCredentialResponse : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,17 +28,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AgentsApiResponseFormat)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(AssetCredentialResponse)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Type)) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.Value.ToString()); - } + writer.WritePropertyName("blobReference"u8); + writer.WriteObjectValue(BlobReference, options); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -56,19 +53,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AgentsApiResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AssetCredentialResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AgentsApiResponseFormat)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(AssetCredentialResponse)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAgentsApiResponseFormat(document.RootElement, options); + return DeserializeAssetCredentialResponse(document.RootElement, options); } - internal static AgentsApiResponseFormat DeserializeAgentsApiResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + internal static AssetCredentialResponse DeserializeAssetCredentialResponse(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -76,18 +73,14 @@ internal static AgentsApiResponseFormat DeserializeAgentsApiResponseFormat(JsonE { return null; } - ResponseFormat? type = default; + BlobReference blobReference = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("type"u8)) + if (property.NameEquals("blobReference"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - type = new ResponseFormat(property.Value.GetString()); + blobReference = BlobReference.DeserializeBlobReference(property.Value, options); continue; } if (options.Format != "W") @@ -96,46 +89,46 @@ internal static AgentsApiResponseFormat DeserializeAgentsApiResponseFormat(JsonE } } serializedAdditionalRawData = rawDataDictionary; - return new AgentsApiResponseFormat(type, serializedAdditionalRawData); + return new AssetCredentialResponse(blobReference, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(AgentsApiResponseFormat)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(AssetCredentialResponse)} does not support writing '{options.Format}' format."); } } - AgentsApiResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + AssetCredentialResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentsApiResponseFormat(document.RootElement, options); + return DeserializeAssetCredentialResponse(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(AgentsApiResponseFormat)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(AssetCredentialResponse)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static AgentsApiResponseFormat FromResponse(Response response) + internal static AssetCredentialResponse FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentsApiResponseFormat(document.RootElement); + return DeserializeAssetCredentialResponse(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AppInsightsProperties.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AssetCredentialResponse.cs similarity index 67% rename from sdk/ai/Azure.AI.Projects/src/Generated/AppInsightsProperties.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AssetCredentialResponse.cs index ce628644fcfa..6e8714d53f43 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AppInsightsProperties.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AssetCredentialResponse.cs @@ -10,8 +10,8 @@ namespace Azure.AI.Projects { - /// The properties of the Application Insights resource. - internal partial class AppInsightsProperties + /// Represents a reference to a blob for consumption. + public partial class AssetCredentialResponse { /// /// Keeps track of any properties unknown to the library. @@ -45,31 +45,31 @@ internal partial class AppInsightsProperties /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// is null. - internal AppInsightsProperties(string connectionString) + /// Initializes a new instance of . + /// Credential info to access the storage account. + /// is null. + internal AssetCredentialResponse(BlobReference blobReference) { - Argument.AssertNotNull(connectionString, nameof(connectionString)); + Argument.AssertNotNull(blobReference, nameof(blobReference)); - ConnectionString = connectionString; + BlobReference = blobReference; } - /// Initializes a new instance of . - /// Authentication type of the connection target. + /// Initializes a new instance of . + /// Credential info to access the storage account. /// Keeps track of any properties unknown to the library. - internal AppInsightsProperties(string connectionString, IDictionary serializedAdditionalRawData) + internal AssetCredentialResponse(BlobReference blobReference, IDictionary serializedAdditionalRawData) { - ConnectionString = connectionString; + BlobReference = blobReference; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal AppInsightsProperties() + /// Initializes a new instance of for deserialization. + internal AssetCredentialResponse() { } - /// Authentication type of the connection target. - public string ConnectionString { get; } + /// Credential info to access the storage account. + public BlobReference BlobReference { get; } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AttackStrategy.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AttackStrategy.cs new file mode 100644 index 000000000000..4b0119e3b1db --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AttackStrategy.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Strategies for attacks. + public readonly partial struct AttackStrategy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AttackStrategy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EasyValue = "easy"; + private const string ModerateValue = "moderate"; + private const string DifficultValue = "difficult"; + private const string AsciiArtValue = "ascii_art"; + private const string AsciiSmugglerValue = "ascii_smuggler"; + private const string AtbashValue = "atbash"; + private const string Base64Value = "base64"; + private const string BinaryValue = "binary"; + private const string CaesarValue = "caesar"; + private const string CharacterSpaceValue = "character_space"; + private const string JailbreakValue = "jailbreak"; + private const string AnsiiAttackValue = "ansii_attack"; + private const string CharacterSwapValue = "character_swap"; + private const string SuffixAppendValue = "suffix_append"; + private const string StringJoinValue = "string_join"; + private const string UnicodeConfusableValue = "unicode_confusable"; + private const string UnicodeSubstitutionValue = "unicode_substitution"; + private const string DiacriticValue = "diacritic"; + private const string FlipValue = "flip"; + private const string LeetspeakValue = "leetspeak"; + private const string ROT13Value = "rot13"; + private const string MorseValue = "morse"; + private const string UrlValue = "url"; + private const string BaselineValue = "baseline"; + + /// Represents a default set of easy complexity attacks. Easy complexity attacks require less effort, such as translation of a prompt into some encoding, and does not require any Large Language Model to convert or orchestrate. + public static AttackStrategy Easy { get; } = new AttackStrategy(EasyValue); + /// Represents a default set of moderate complexity attacks. Moderate complexity attacks require having access to resources such as another generative AI model. + public static AttackStrategy Moderate { get; } = new AttackStrategy(ModerateValue); + /// Represents a default set of difficult complexity attacks. Difficult complexity attacks include attacks that require access to significant resources and effort to execute an attack such as knowledge of search-based algorithms in addition to a generative AI model. + public static AttackStrategy Difficult { get; } = new AttackStrategy(DifficultValue); + /// Generates visual art using ASCII characters, often used for creative or obfuscation purposes. + public static AttackStrategy AsciiArt { get; } = new AttackStrategy(AsciiArtValue); + /// Conceals data within ASCII characters, making it harder to detect. + public static AttackStrategy AsciiSmuggler { get; } = new AttackStrategy(AsciiSmugglerValue); + /// Implements the Atbash cipher, a simple substitution cipher where each letter is mapped to its reverse. + public static AttackStrategy Atbash { get; } = new AttackStrategy(AtbashValue); + /// Encodes binary data into a text format using Base64, commonly used for data transmission. + public static AttackStrategy Base64 { get; } = new AttackStrategy(Base64Value); + /// Converts text into binary code, representing data in a series of 0s and 1s. + public static AttackStrategy Binary { get; } = new AttackStrategy(BinaryValue); + /// Applies the Caesar cipher, a substitution cipher that shifts characters by a fixed number of positions. + public static AttackStrategy Caesar { get; } = new AttackStrategy(CaesarValue); + /// Alters text by adding spaces between characters, often used for obfuscation. + public static AttackStrategy CharacterSpace { get; } = new AttackStrategy(CharacterSpaceValue); + /// Injects specially crafted prompts to bypass AI safeguards, known as User Injected Prompt Attacks (UPIA). + public static AttackStrategy Jailbreak { get; } = new AttackStrategy(JailbreakValue); + /// Utilizes ANSI escape sequences to manipulate text appearance and behavior. + public static AttackStrategy AnsiiAttack { get; } = new AttackStrategy(AnsiiAttackValue); + /// Swaps characters within text to create variations or obfuscate the original content. + public static AttackStrategy CharacterSwap { get; } = new AttackStrategy(CharacterSwapValue); + /// Appends an adversarial suffix to the prompt. + public static AttackStrategy SuffixAppend { get; } = new AttackStrategy(SuffixAppendValue); + /// Joins multiple strings together, often used for concatenation or obfuscation. + public static AttackStrategy StringJoin { get; } = new AttackStrategy(StringJoinValue); + /// Uses Unicode characters that look similar to standard characters, creating visual confusion. + public static AttackStrategy UnicodeConfusable { get; } = new AttackStrategy(UnicodeConfusableValue); + /// Substitutes standard characters with Unicode equivalents, often for obfuscation. + public static AttackStrategy UnicodeSubstitution { get; } = new AttackStrategy(UnicodeSubstitutionValue); + /// Adds diacritical marks to characters, changing their appearance and sometimes their meaning. + public static AttackStrategy Diacritic { get; } = new AttackStrategy(DiacriticValue); + /// Flips characters from front to back, creating a mirrored effect. + public static AttackStrategy Flip { get; } = new AttackStrategy(FlipValue); + /// Transforms text into Leetspeak, a form of encoding that replaces letters with similar-looking numbers or symbols. + public static AttackStrategy Leetspeak { get; } = new AttackStrategy(LeetspeakValue); + /// Applies the ROT13 cipher, a simple substitution cipher that shifts characters by 13 positions. + public static AttackStrategy ROT13 { get; } = new AttackStrategy(ROT13Value); + /// Encodes text into Morse code, using dots and dashes to represent characters. + public static AttackStrategy Morse { get; } = new AttackStrategy(MorseValue); + /// Encodes text into URL format. + public static AttackStrategy Url { get; } = new AttackStrategy(UrlValue); + /// Represents the baseline direct adversarial probing, which is used by attack strategies as the attack objective. + public static AttackStrategy Baseline { get; } = new AttackStrategy(BaselineValue); + /// Determines if two values are the same. + public static bool operator ==(AttackStrategy left, AttackStrategy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AttackStrategy left, AttackStrategy right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AttackStrategy(string value) => new AttackStrategy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AttackStrategy other && Equals(other); + /// + public bool Equals(AttackStrategy 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/sdk/ai/Azure.AI.Projects/src/Generated/AuthenticationType.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AuthenticationType.Serialization.cs deleted file mode 100644 index 40f375b55a99..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AuthenticationType.Serialization.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.AI.Projects -{ - internal static partial class AuthenticationTypeExtensions - { - public static string ToSerialString(this AuthenticationType value) => value switch - { - AuthenticationType.ApiKey => "ApiKey", - AuthenticationType.EntraId => "AAD", - AuthenticationType.SAS => "SAS", - AuthenticationType.Custom => "CustomKeys", - AuthenticationType.None => "None", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AuthenticationType value.") - }; - - public static AuthenticationType ToAuthenticationType(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ApiKey")) return AuthenticationType.ApiKey; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AAD")) return AuthenticationType.EntraId; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "SAS")) return AuthenticationType.SAS; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomKeys")) return AuthenticationType.Custom; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) return AuthenticationType.None; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AuthenticationType value."); - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AuthenticationType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AuthenticationType.cs deleted file mode 100644 index 13808106dd47..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AuthenticationType.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.AI.Projects -{ - /// Authentication type used by Azure AI service to connect to another service. - public enum AuthenticationType - { - /// API Key authentication. - ApiKey, - /// Entra ID authentication (formerly known as AAD). - EntraId, - /// Shared Access Signature (SAS) authentication. - SAS, - /// Custom authentication. - Custom, - /// No authentication. - None - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchIndex.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchIndex.Serialization.cs new file mode 100644 index 000000000000..225ec9c4b9fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchIndex.Serialization.cs @@ -0,0 +1,206 @@ +// 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 AzureAISearchIndex : 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(AzureAISearchIndex)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + writer.WritePropertyName("indexName"u8); + writer.WriteStringValue(IndexName); + if (Optional.IsDefined(FieldMapping)) + { + writer.WritePropertyName("fieldMapping"u8); + writer.WriteObjectValue(FieldMapping, options); + } + } + + AzureAISearchIndex 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(AzureAISearchIndex)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchIndex(document.RootElement, options); + } + + internal static AzureAISearchIndex DeserializeAzureAISearchIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionName = default; + string indexName = default; + FieldMapping fieldMapping = default; + IndexType type = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("indexName"u8)) + { + indexName = property.Value.GetString(); + continue; + } + if (property.NameEquals("fieldMapping"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fieldMapping = FieldMapping.DeserializeFieldMapping(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new IndexType(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureAISearchIndex( + type, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData, + connectionName, + indexName, + fieldMapping); + } + + 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, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAISearchIndex)} does not support writing '{options.Format}' format."); + } + } + + AzureAISearchIndex 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 DeserializeAzureAISearchIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchIndex)} 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 AzureAISearchIndex FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureAISearchIndex(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/AzureAISearchIndex.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchIndex.cs new file mode 100644 index 000000000000..bef85c881912 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchIndex.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Azure AI Search Index Definition. + public partial class AzureAISearchIndex : Index + { + /// Initializes a new instance of . + /// Name of connection to Azure AI Search. + /// Name of index in Azure AI Search resource to attach. + /// or is null. + public AzureAISearchIndex(string connectionName, string indexName) + { + Argument.AssertNotNull(connectionName, nameof(connectionName)); + Argument.AssertNotNull(indexName, nameof(indexName)); + + Type = IndexType.AzureSearch; + ConnectionName = connectionName; + IndexName = indexName; + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + /// Name of connection to Azure AI Search. + /// Name of index in Azure AI Search resource to attach. + /// Field mapping configuration. + internal AzureAISearchIndex(IndexType type, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData, string connectionName, string indexName, FieldMapping fieldMapping) : base(type, id, name, version, description, tags, serializedAdditionalRawData) + { + ConnectionName = connectionName; + IndexName = indexName; + FieldMapping = fieldMapping; + } + + /// Initializes a new instance of for deserialization. + internal AzureAISearchIndex() + { + } + + /// Name of connection to Azure AI Search. + public string ConnectionName { get; set; } + /// Name of index in Azure AI Search resource to attach. + public string IndexName { get; set; } + /// Field mapping configuration. + public FieldMapping FieldMapping { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchQueryType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchQueryType.cs deleted file mode 100644 index 731f00c9211f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchQueryType.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Available query types for Azure AI Search tool. - public readonly partial struct AzureAISearchQueryType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AzureAISearchQueryType(string value) - { - _value = value ?? throw new ArgumentNullException(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"; - - /// Query type `simple`. - public static AzureAISearchQueryType Simple { get; } = new AzureAISearchQueryType(SimpleValue); - /// Query type `semantic`. - public static AzureAISearchQueryType Semantic { get; } = new AzureAISearchQueryType(SemanticValue); - /// Query type `vector`. - public static AzureAISearchQueryType Vector { get; } = new AzureAISearchQueryType(VectorValue); - /// Query type `vector_simple_hybrid`. - public static AzureAISearchQueryType VectorSimpleHybrid { get; } = new AzureAISearchQueryType(VectorSimpleHybridValue); - /// Query type `vector_semantic_hybrid`. - public static AzureAISearchQueryType VectorSemanticHybrid { get; } = new AzureAISearchQueryType(VectorSemanticHybridValue); - /// Determines if two values are the same. - public static bool operator ==(AzureAISearchQueryType left, AzureAISearchQueryType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(AzureAISearchQueryType left, AzureAISearchQueryType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AzureAISearchQueryType(string value) => new AzureAISearchQueryType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AzureAISearchQueryType other && Equals(other); - /// - public bool Equals(AzureAISearchQueryType 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/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchResource.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchResource.Serialization.cs deleted file mode 100644 index 451993b02c5d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchResource.Serialization.cs +++ /dev/null @@ -1,159 +0,0 @@ -// 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 AzureAISearchResource : 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(AzureAISearchResource)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(IndexList)) - { - writer.WritePropertyName("indexes"u8); - writer.WriteStartArray(); - foreach (var item in IndexList) - { - 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 - } - } - } - - AzureAISearchResource 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(AzureAISearchResource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAzureAISearchResource(document.RootElement, options); - } - - internal static AzureAISearchResource DeserializeAzureAISearchResource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList indexes = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("indexes"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(AISearchIndexResource.DeserializeAISearchIndexResource(item, options)); - } - indexes = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AzureAISearchResource(indexes ?? 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AzureAISearchResource)} does not support writing '{options.Format}' format."); - } - } - - AzureAISearchResource 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 DeserializeAzureAISearchResource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AzureAISearchResource)} 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 AzureAISearchResource FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAzureAISearchResource(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/AzureAISearchResource.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchResource.cs deleted file mode 100644 index 9ecdd9b7a676..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchResource.cs +++ /dev/null @@ -1,72 +0,0 @@ -// 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 set of index resources used by the `azure_ai_search` tool. - public partial class AzureAISearchResource - { - /// - /// 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 . - public AzureAISearchResource() - { - IndexList = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// - /// The indices attached to this agent. There can be a maximum of 1 index - /// resource attached to the agent. - /// - /// Keeps track of any properties unknown to the library. - internal AzureAISearchResource(IList indexList, IDictionary serializedAdditionalRawData) - { - IndexList = indexList; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// The indices attached to this agent. There can be a maximum of 1 index - /// resource attached to the agent. - /// - public IList IndexList { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolDefinition.cs deleted file mode 100644 index b8e95d87f7ab..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolDefinition.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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 an Azure AI search tool as used to configure an agent. - public partial class AzureAISearchToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - public AzureAISearchToolDefinition() - { - Type = "azure_ai_search"; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal AzureAISearchToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.Serialization.cs deleted file mode 100644 index c4f00eb7f66e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 AzureFunctionBinding : 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(AzureFunctionBinding)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - writer.WritePropertyName("storage_queue"u8); - writer.WriteObjectValue(StorageQueue, options); - 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 - } - } - } - - AzureFunctionBinding 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(AzureFunctionBinding)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAzureFunctionBinding(document.RootElement, options); - } - - internal static AzureFunctionBinding DeserializeAzureFunctionBinding(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AzureFunctionBindingType type = default; - AzureFunctionStorageQueue storageQueue = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new AzureFunctionBindingType(property.Value.GetString()); - continue; - } - if (property.NameEquals("storage_queue"u8)) - { - storageQueue = AzureFunctionStorageQueue.DeserializeAzureFunctionStorageQueue(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AzureFunctionBinding(type, storageQueue, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support writing '{options.Format}' format."); - } - } - - AzureFunctionBinding 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 DeserializeAzureFunctionBinding(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AzureFunctionBinding)} 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 AzureFunctionBinding FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAzureFunctionBinding(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/AzureFunctionBindingType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBindingType.cs deleted file mode 100644 index d3ef7652d782..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBindingType.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The AzureFunctionBinding_type. - public readonly partial struct AzureFunctionBindingType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public AzureFunctionBindingType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string StorageQueueValue = "storage_queue"; - - /// storage_queue. - public static AzureFunctionBindingType StorageQueue { get; } = new AzureFunctionBindingType(StorageQueueValue); - /// Determines if two values are the same. - public static bool operator ==(AzureFunctionBindingType left, AzureFunctionBindingType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(AzureFunctionBindingType left, AzureFunctionBindingType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator AzureFunctionBindingType(string value) => new AzureFunctionBindingType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AzureFunctionBindingType other && Equals(other); - /// - public bool Equals(AzureFunctionBindingType 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/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.Serialization.cs deleted file mode 100644 index 7e928c6d38d7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 AzureFunctionStorageQueue : 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(AzureFunctionStorageQueue)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("queue_service_endpoint"u8); - writer.WriteStringValue(StorageServiceEndpoint); - writer.WritePropertyName("queue_name"u8); - writer.WriteStringValue(QueueName); - 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 - } - } - } - - AzureFunctionStorageQueue 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(AzureFunctionStorageQueue)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAzureFunctionStorageQueue(document.RootElement, options); - } - - internal static AzureFunctionStorageQueue DeserializeAzureFunctionStorageQueue(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string queueServiceEndpoint = default; - string queueName = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("queue_service_endpoint"u8)) - { - queueServiceEndpoint = property.Value.GetString(); - continue; - } - if (property.NameEquals("queue_name"u8)) - { - queueName = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AzureFunctionStorageQueue(queueServiceEndpoint, queueName, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support writing '{options.Format}' format."); - } - } - - AzureFunctionStorageQueue 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 DeserializeAzureFunctionStorageQueue(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} 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 AzureFunctionStorageQueue FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAzureFunctionStorageQueue(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/AzureFunctionToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionToolDefinition.Serialization.cs deleted file mode 100644 index b98aeece3d58..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionToolDefinition.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 AzureFunctionToolDefinition : 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(AzureFunctionToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("azure_function"u8); - writer.WriteObjectValue(InternalAzureFunction, options); - } - - AzureFunctionToolDefinition 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(AzureFunctionToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAzureFunctionToolDefinition(document.RootElement, options); - } - - internal static AzureFunctionToolDefinition DeserializeAzureFunctionToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalAzureFunctionDefinition azureFunction = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("azure_function"u8)) - { - azureFunction = InternalAzureFunctionDefinition.DeserializeInternalAzureFunctionDefinition(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 AzureFunctionToolDefinition(type, serializedAdditionalRawData, azureFunction); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(AzureFunctionToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - AzureFunctionToolDefinition 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 DeserializeAzureFunctionToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AzureFunctionToolDefinition)} 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 AzureFunctionToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAzureFunctionToolDefinition(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/AzureFunctionToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionToolDefinition.cs deleted file mode 100644 index 87032b76e501..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionToolDefinition.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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 azure function tool as used to configure an agent. - public partial class AzureFunctionToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The definition of the concrete function that the function tool should call. - internal AzureFunctionToolDefinition(string type, IDictionary serializedAdditionalRawData, InternalAzureFunctionDefinition internalAzureFunction) : base(type, serializedAdditionalRawData) - { - InternalAzureFunction = internalAzureFunction; - } - - /// Initializes a new instance of for deserialization. - internal AzureFunctionToolDefinition() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.Serialization.cs similarity index 65% rename from sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricToolDefinition.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.Serialization.cs index bf986513c68a..4cfc10eb6ce1 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricToolDefinition.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class MicrosoftFabricToolDefinition : IUtf8JsonSerializable, IJsonModel + public partial class AzureOpenAIModelConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,30 +28,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MicrosoftFabricToolDefinition)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(AzureOpenAIModelConfiguration)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("fabric_dataagent"u8); - writer.WriteObjectValue(FabricDataagent, options); + writer.WritePropertyName("modelDeploymentName"u8); + writer.WriteStringValue(ModelDeploymentName); } - MicrosoftFabricToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AzureOpenAIModelConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MicrosoftFabricToolDefinition)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(AzureOpenAIModelConfiguration)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMicrosoftFabricToolDefinition(document.RootElement, options); + return DeserializeAzureOpenAIModelConfiguration(document.RootElement, options); } - internal static MicrosoftFabricToolDefinition DeserializeMicrosoftFabricToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + internal static AzureOpenAIModelConfiguration DeserializeAzureOpenAIModelConfiguration(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -59,15 +59,15 @@ internal static MicrosoftFabricToolDefinition DeserializeMicrosoftFabricToolDefi { return null; } - ToolConnectionList fabricDataagent = default; + string modelDeploymentName = default; string type = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("fabric_dataagent"u8)) + if (property.NameEquals("modelDeploymentName"u8)) { - fabricDataagent = ToolConnectionList.DeserializeToolConnectionList(property.Value, options); + modelDeploymentName = property.Value.GetString(); continue; } if (property.NameEquals("type"u8)) @@ -81,46 +81,46 @@ internal static MicrosoftFabricToolDefinition DeserializeMicrosoftFabricToolDefi } } serializedAdditionalRawData = rawDataDictionary; - return new MicrosoftFabricToolDefinition(type, serializedAdditionalRawData, fabricDataagent); + return new AzureOpenAIModelConfiguration(type, serializedAdditionalRawData, modelDeploymentName); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(MicrosoftFabricToolDefinition)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(AzureOpenAIModelConfiguration)} does not support writing '{options.Format}' format."); } } - MicrosoftFabricToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + AzureOpenAIModelConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMicrosoftFabricToolDefinition(document.RootElement, options); + return DeserializeAzureOpenAIModelConfiguration(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(MicrosoftFabricToolDefinition)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(AzureOpenAIModelConfiguration)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new MicrosoftFabricToolDefinition FromResponse(Response response) + internal static new AzureOpenAIModelConfiguration FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMicrosoftFabricToolDefinition(document.RootElement); + return DeserializeAzureOpenAIModelConfiguration(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.cs new file mode 100644 index 000000000000..bba0687cbc42 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.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 +{ + /// Azure OpenAI model configuration. The API version would be selected by the service for querying the model. + public partial class AzureOpenAIModelConfiguration : TargetConfig + { + /// Initializes a new instance of . + /// Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (i.e. `my-aoai-connection/gpt-4o`. + /// is null. + public AzureOpenAIModelConfiguration(string modelDeploymentName) + { + Argument.AssertNotNull(modelDeploymentName, nameof(modelDeploymentName)); + + Type = "AzureOpenAIModel"; + ModelDeploymentName = modelDeploymentName; + } + + /// Initializes a new instance of . + /// Type of the model configuration. + /// Keeps track of any properties unknown to the library. + /// Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (i.e. `my-aoai-connection/gpt-4o`. + internal AzureOpenAIModelConfiguration(string type, IDictionary serializedAdditionalRawData, string modelDeploymentName) : base(type, serializedAdditionalRawData) + { + ModelDeploymentName = modelDeploymentName; + } + + /// Initializes a new instance of for deserialization. + internal AzureOpenAIModelConfiguration() + { + } + + /// Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (i.e. `my-aoai-connection/gpt-4o`. + public string ModelDeploymentName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BaseCredentials.Serialization.cs similarity index 58% rename from sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/BaseCredentials.Serialization.cs index 8c24963a5b8f..c686b983eff7 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BaseCredentials.Serialization.cs @@ -12,12 +12,12 @@ namespace Azure.AI.Projects { - [PersistableModelProxy(typeof(UnknownMessageInputContentBlock))] - public partial class MessageInputContentBlock : IUtf8JsonSerializable, IJsonModel + [PersistableModelProxy(typeof(UnknownBaseCredentials))] + public partial class BaseCredentials : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,10 +28,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(BaseCredentials)} does not support writing '{format}' format."); } writer.WritePropertyName("type"u8); @@ -53,19 +53,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MessageInputContentBlock IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + BaseCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(BaseCredentials)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageInputContentBlock(document.RootElement, options); + return DeserializeBaseCredentials(document.RootElement, options); } - internal static MessageInputContentBlock DeserializeMessageInputContentBlock(JsonElement element, ModelReaderWriterOptions options = null) + internal static BaseCredentials DeserializeBaseCredentials(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,51 +77,53 @@ internal static MessageInputContentBlock DeserializeMessageInputContentBlock(Jso { switch (discriminator.GetString()) { - case "image_file": return MessageInputImageFileBlock.DeserializeMessageInputImageFileBlock(element, options); - case "image_url": return MessageInputImageUrlBlock.DeserializeMessageInputImageUrlBlock(element, options); - case "text": return MessageInputTextBlock.DeserializeMessageInputTextBlock(element, options); + case "AAD": return EntraIDCredentials.DeserializeEntraIDCredentials(element, options); + case "ApiKey": return ApiKeyCredentials.DeserializeApiKeyCredentials(element, options); + case "CustomKeys": return CustomCredential.DeserializeCustomCredential(element, options); + case "None": return NoAuthenticationCredentials.DeserializeNoAuthenticationCredentials(element, options); + case "SAS": return SASCredentials.DeserializeSASCredentials(element, options); } } - return UnknownMessageInputContentBlock.DeserializeUnknownMessageInputContentBlock(element, options); + return UnknownBaseCredentials.DeserializeUnknownBaseCredentials(element, options); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(BaseCredentials)} does not support writing '{options.Format}' format."); } } - MessageInputContentBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + BaseCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageInputContentBlock(document.RootElement, options); + return DeserializeBaseCredentials(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(BaseCredentials)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static MessageInputContentBlock FromResponse(Response response) + internal static BaseCredentials FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageInputContentBlock(document.RootElement); + return DeserializeBaseCredentials(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BaseCredentials.cs similarity index 63% rename from sdk/ai/Azure.AI.Projects/src/Generated/MessageContent.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/BaseCredentials.cs index 17682f30308e..833c918e22ca 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageContent.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BaseCredentials.cs @@ -11,11 +11,11 @@ namespace Azure.AI.Projects { /// - /// An abstract representation of a single item of thread message content. - /// 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 . + /// A base class for connection credentials + /// 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 MessageContent + public abstract partial class BaseCredentials { /// /// Keeps track of any properties unknown to the library. @@ -49,21 +49,21 @@ public abstract partial class MessageContent /// private protected IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - protected MessageContent() + /// Initializes a new instance of . + protected BaseCredentials() { } - /// Initializes a new instance of . - /// The object type. + /// Initializes a new instance of . + /// The type of credential used by the connection. /// Keeps track of any properties unknown to the library. - internal MessageContent(string type, IDictionary serializedAdditionalRawData) + internal BaseCredentials(CredentialType type, IDictionary serializedAdditionalRawData) { Type = type; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// The object type. - internal string Type { get; set; } + /// The type of credential used by the connection. + internal CredentialType Type { get; set; } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.Serialization.cs deleted file mode 100644 index 71befeab196b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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, AzureAIProjectsContext.Default); - 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 deleted file mode 100644 index 4e6749dbfe5b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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/BingGroundingToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingToolDefinition.Serialization.cs deleted file mode 100644 index 245db11839bf..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingToolDefinition.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 BingGroundingToolDefinition : 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(BingGroundingToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("bing_grounding"u8); - writer.WriteObjectValue(BingGrounding, options); - } - - BingGroundingToolDefinition 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(BingGroundingToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeBingGroundingToolDefinition(document.RootElement, options); - } - - internal static BingGroundingToolDefinition DeserializeBingGroundingToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ToolConnectionList bingGrounding = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("bing_grounding"u8)) - { - bingGrounding = ToolConnectionList.DeserializeToolConnectionList(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 BingGroundingToolDefinition(type, serializedAdditionalRawData, bingGrounding); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(BingGroundingToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - BingGroundingToolDefinition 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 DeserializeBingGroundingToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(BingGroundingToolDefinition)} 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 BingGroundingToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeBingGroundingToolDefinition(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/BingGroundingToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingToolDefinition.cs deleted file mode 100644 index a43df24739de..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingToolDefinition.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 grounding search tool as used to configure an agent. - public partial class BingGroundingToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - /// The list of connections used by the bing grounding tool. - /// is null. - public BingGroundingToolDefinition(ToolConnectionList bingGrounding) - { - Argument.AssertNotNull(bingGrounding, nameof(bingGrounding)); - - Type = "bing_grounding"; - BingGrounding = bingGrounding; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The list of connections used by the bing grounding tool. - internal BingGroundingToolDefinition(string type, IDictionary serializedAdditionalRawData, ToolConnectionList bingGrounding) : base(type, serializedAdditionalRawData) - { - BingGrounding = bingGrounding; - } - - /// Initializes a new instance of for deserialization. - internal BingGroundingToolDefinition() - { - } - - /// The list of connections used by the bing grounding tool. - public ToolConnectionList BingGrounding { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BlobReference.Serialization.cs similarity index 59% rename from sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatus.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/BlobReference.Serialization.cs index d9ab94ac1fd1..91ffecb7bb29 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatus.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BlobReference.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class ThreadDeletionStatus : IUtf8JsonSerializable, IJsonModel + public partial class BlobReference : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,18 +28,18 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(BlobReference)} does not support writing '{format}' format."); } - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("blobUri"u8); + writer.WriteStringValue(BlobUri); + writer.WritePropertyName("storageAccountArmId"u8); + writer.WriteStringValue(StorageAccountArmId); + writer.WritePropertyName("credential"u8); + writer.WriteObjectValue(Credential, options); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -57,19 +57,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ThreadDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + BlobReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(BlobReference)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadDeletionStatus(document.RootElement, options); + return DeserializeBlobReference(document.RootElement, options); } - internal static ThreadDeletionStatus DeserializeThreadDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + internal static BlobReference DeserializeBlobReference(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,26 +77,26 @@ internal static ThreadDeletionStatus DeserializeThreadDeletionStatus(JsonElement { return null; } - string id = default; - bool deleted = default; - ThreadDeletionStatusObject @object = default; + string blobUri = default; + string storageAccountArmId = default; + SasCredential credential = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (property.NameEquals("blobUri"u8)) { - id = property.Value.GetString(); + blobUri = property.Value.GetString(); continue; } - if (property.NameEquals("deleted"u8)) + if (property.NameEquals("storageAccountArmId"u8)) { - deleted = property.Value.GetBoolean(); + storageAccountArmId = property.Value.GetString(); continue; } - if (property.NameEquals("object"u8)) + if (property.NameEquals("credential"u8)) { - @object = new ThreadDeletionStatusObject(property.Value.GetString()); + credential = SasCredential.DeserializeSasCredential(property.Value, options); continue; } if (options.Format != "W") @@ -105,46 +105,46 @@ internal static ThreadDeletionStatus DeserializeThreadDeletionStatus(JsonElement } } serializedAdditionalRawData = rawDataDictionary; - return new ThreadDeletionStatus(id, deleted, @object, serializedAdditionalRawData); + return new BlobReference(blobUri, storageAccountArmId, credential, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(BlobReference)} does not support writing '{options.Format}' format."); } } - ThreadDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + BlobReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeThreadDeletionStatus(document.RootElement, options); + return DeserializeBlobReference(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(BlobReference)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static ThreadDeletionStatus FromResponse(Response response) + internal static BlobReference FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeThreadDeletionStatus(document.RootElement); + return DeserializeBlobReference(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BlobReference.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BlobReference.cs new file mode 100644 index 000000000000..1781d55fc026 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BlobReference.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Blob reference details. + public partial class BlobReference + { + /// + /// 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 . + /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// ARM ID of the storage account to use. + /// Credential info to access the storage account. + /// , or is null. + internal BlobReference(string blobUri, string storageAccountArmId, SasCredential credential) + { + Argument.AssertNotNull(blobUri, nameof(blobUri)); + Argument.AssertNotNull(storageAccountArmId, nameof(storageAccountArmId)); + Argument.AssertNotNull(credential, nameof(credential)); + + BlobUri = blobUri; + StorageAccountArmId = storageAccountArmId; + Credential = credential; + } + + /// Initializes a new instance of . + /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// ARM ID of the storage account to use. + /// Credential info to access the storage account. + /// Keeps track of any properties unknown to the library. + internal BlobReference(string blobUri, string storageAccountArmId, SasCredential credential, IDictionary serializedAdditionalRawData) + { + BlobUri = blobUri; + StorageAccountArmId = storageAccountArmId; + Credential = credential; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BlobReference() + { + } + + /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + public string BlobUri { get; } + /// ARM ID of the storage account to use. + public string StorageAccountArmId { get; } + /// Credential info to access the storage account. + public SasCredential Credential { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolDefinition.Serialization.cs deleted file mode 100644 index 7dcd5629f274..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolDefinition.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 CodeInterpreterToolDefinition : 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(CodeInterpreterToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - CodeInterpreterToolDefinition 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(CodeInterpreterToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); - } - - internal static CodeInterpreterToolDefinition DeserializeCodeInterpreterToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - 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()) - { - 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 CodeInterpreterToolDefinition(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - CodeInterpreterToolDefinition 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 DeserializeCodeInterpreterToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} 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 CodeInterpreterToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCodeInterpreterToolDefinition(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/CodeInterpreterToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolDefinition.cs deleted file mode 100644 index fbcc0b2aa891..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolDefinition.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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 code interpreter tool as used to configure an agent. - public partial class CodeInterpreterToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - public CodeInterpreterToolDefinition() - { - Type = "code_interpreter"; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal CodeInterpreterToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolResource.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolResource.Serialization.cs deleted file mode 100644 index 1bb1bd95dc21..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolResource.Serialization.cs +++ /dev/null @@ -1,184 +0,0 @@ -// 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 CodeInterpreterToolResource : 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(CodeInterpreterToolResource)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(FileIds)) - { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(DataSources)) - { - writer.WritePropertyName("data_sources"u8); - writer.WriteStartArray(); - foreach (var item in DataSources) - { - 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 - } - } - } - - CodeInterpreterToolResource 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(CodeInterpreterToolResource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCodeInterpreterToolResource(document.RootElement, options); - } - - internal static CodeInterpreterToolResource DeserializeCodeInterpreterToolResource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - IList dataSources = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_ids"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; - continue; - } - if (property.NameEquals("data_sources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(VectorStoreDataSource.DeserializeVectorStoreDataSource(item, options)); - } - dataSources = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CodeInterpreterToolResource(fileIds ?? new ChangeTrackingList(), dataSources ?? 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support writing '{options.Format}' format."); - } - } - - CodeInterpreterToolResource 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 DeserializeCodeInterpreterToolResource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} 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 CodeInterpreterToolResource FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCodeInterpreterToolResource(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/CodeInterpreterToolResource.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolResource.cs deleted file mode 100644 index 5eebfab8f085..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterToolResource.cs +++ /dev/null @@ -1,77 +0,0 @@ -// 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 set of resources that are used by the `code_interpreter` tool. - public partial class CodeInterpreterToolResource - { - /// - /// 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 . - public CodeInterpreterToolResource() - { - FileIds = new ChangeTrackingList(); - DataSources = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// - /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - /// associated with the tool. - /// - /// The data sources to be used. This option is mutually exclusive with the `fileIds` property. - /// Keeps track of any properties unknown to the library. - internal CodeInterpreterToolResource(IList fileIds, IList dataSources, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - DataSources = dataSources; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - /// associated with the tool. - /// - public IList FileIds { get; } - /// The data sources to be used. This option is mutually exclusive with the `fileIds` property. - public IList DataSources { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentDetails.cs deleted file mode 100644 index 48727e8310ff..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentDetails.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Information for connecting one agent to another as a tool. - public partial class ConnectedAgentDetails - { - /// - /// 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 identifier of the child agent. - /// The name of the agent to be called. - /// A description of what the agent does, used by the model to choose when and how to call the agent. - /// , or is null. - public ConnectedAgentDetails(string id, string name, string description) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(description, nameof(description)); - - Id = id; - Name = name; - Description = description; - } - - /// Initializes a new instance of . - /// The identifier of the child agent. - /// The name of the agent to be called. - /// A description of what the agent does, used by the model to choose when and how to call the agent. - /// Keeps track of any properties unknown to the library. - internal ConnectedAgentDetails(string id, string name, string description, IDictionary serializedAdditionalRawData) - { - Id = id; - Name = name; - Description = description; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ConnectedAgentDetails() - { - } - - /// The identifier of the child agent. - public string Id { get; set; } - /// The name of the agent to be called. - public string Name { get; set; } - /// A description of what the agent does, used by the model to choose when and how to call the agent. - public string Description { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentToolDefinition.Serialization.cs deleted file mode 100644 index 30a66cd9bc16..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentToolDefinition.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 ConnectedAgentToolDefinition : 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(ConnectedAgentToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("connected_agent"u8); - writer.WriteObjectValue(ConnectedAgent, options); - } - - ConnectedAgentToolDefinition 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(ConnectedAgentToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeConnectedAgentToolDefinition(document.RootElement, options); - } - - internal static ConnectedAgentToolDefinition DeserializeConnectedAgentToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ConnectedAgentDetails connectedAgent = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("connected_agent"u8)) - { - connectedAgent = ConnectedAgentDetails.DeserializeConnectedAgentDetails(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 ConnectedAgentToolDefinition(type, serializedAdditionalRawData, connectedAgent); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ConnectedAgentToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - ConnectedAgentToolDefinition 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 DeserializeConnectedAgentToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ConnectedAgentToolDefinition)} 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 ConnectedAgentToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeConnectedAgentToolDefinition(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/ConnectedAgentToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentToolDefinition.cs deleted file mode 100644 index 563a676c62a3..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentToolDefinition.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 connected agent tool which defines a domain specific sub-agent. - public partial class ConnectedAgentToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - /// The sub-agent to connect. - /// is null. - public ConnectedAgentToolDefinition(ConnectedAgentDetails connectedAgent) - { - Argument.AssertNotNull(connectedAgent, nameof(connectedAgent)); - - Type = "connected_agent"; - ConnectedAgent = connectedAgent; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The sub-agent to connect. - internal ConnectedAgentToolDefinition(string type, IDictionary serializedAdditionalRawData, ConnectedAgentDetails connectedAgent) : base(type, serializedAdditionalRawData) - { - ConnectedAgent = connectedAgent; - } - - /// Initializes a new instance of for deserialization. - internal ConnectedAgentToolDefinition() - { - } - - /// The sub-agent to connect. - public ConnectedAgentDetails ConnectedAgent { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Connection.Serialization.cs similarity index 58% rename from sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/Connection.Serialization.cs index 31ebe0a704e8..cb5828e40f13 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Connection.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class AgentThread : IUtf8JsonSerializable, IJsonModel + public partial class Connection : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,28 +28,43 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AgentThread)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(Connection)} does not support writing '{format}' format."); } - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - if (ToolResources != null) + if (options.Format != "W") { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - else + if (options.Format != "W") { - writer.WriteNull("tool_resources"); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); } - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (options.Format != "W") + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (options.Format != "W") + { + writer.WritePropertyName("isDefault"u8); + writer.WriteBooleanValue(IsDefault); + } + if (options.Format != "W") + { + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + } + if (options.Format != "W") { writer.WritePropertyName("metadata"u8); writer.WriteStartObject(); @@ -60,10 +75,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WriteEndObject(); } - else - { - writer.WriteNull("metadata"); - } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -81,19 +92,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AgentThread IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + Connection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AgentThread)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(Connection)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAgentThread(document.RootElement, options); + return DeserializeConnection(document.RootElement, options); } - internal static AgentThread DeserializeAgentThread(JsonElement element, ModelReaderWriterOptions options = null) + internal static Connection DeserializeConnection(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -101,47 +112,49 @@ internal static AgentThread DeserializeAgentThread(JsonElement element, ModelRea { return null; } + string name = default; string id = default; - string @object = default; - DateTimeOffset createdAt = default; - ToolResources toolResources = default; + ConnectionType type = default; + string target = default; + bool isDefault = default; + BaseCredentials credentials = default; IReadOnlyDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } if (property.NameEquals("id"u8)) { id = property.Value.GetString(); continue; } - if (property.NameEquals("object"u8)) + if (property.NameEquals("type"u8)) { - @object = property.Value.GetString(); + type = new ConnectionType(property.Value.GetString()); continue; } - if (property.NameEquals("created_at"u8)) + if (property.NameEquals("target"u8)) { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + target = property.Value.GetString(); continue; } - if (property.NameEquals("tool_resources"u8)) + if (property.NameEquals("isDefault"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = ToolResources.DeserializeToolResources(property.Value, options); + isDefault = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("credentials"u8)) + { + credentials = BaseCredentials.DeserializeBaseCredentials(property.Value, options); continue; } if (property.NameEquals("metadata"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { @@ -156,52 +169,54 @@ internal static AgentThread DeserializeAgentThread(JsonElement element, ModelRea } } serializedAdditionalRawData = rawDataDictionary; - return new AgentThread( + return new Connection( + name, id, - @object, - createdAt, - toolResources, + type, + target, + isDefault, + credentials, metadata, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(AgentThread)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(Connection)} does not support writing '{options.Format}' format."); } } - AgentThread IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + Connection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentThread(document.RootElement, options); + return DeserializeConnection(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(AgentThread)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(Connection)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static AgentThread FromResponse(Response response) + internal static Connection FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAgentThread(document.RootElement); + return DeserializeConnection(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Connection.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Connection.cs new file mode 100644 index 000000000000..1ef963bc4aa6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Connection.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Response from the list and get connections operations. + public partial class Connection + { + /// + /// 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 . + internal Connection() + { + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The friendly name of the connection, provided by the user. + /// A unique identifier for the connection, generated by the service. + /// Category of the connection. + /// The connection URL to be used for this service. + /// Whether the connection is tagged as the default connection of its type. + /// + /// The credentials used by the connection + /// 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 . + /// + /// Metadata of the connection. + /// Keeps track of any properties unknown to the library. + internal Connection(string name, string id, ConnectionType type, string target, bool isDefault, BaseCredentials credentials, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Name = name; + Id = id; + Type = type; + Target = target; + IsDefault = isDefault; + Credentials = credentials; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The friendly name of the connection, provided by the user. + public string Name { get; } + /// A unique identifier for the connection, generated by the service. + public string Id { get; } + /// Category of the connection. + public ConnectionType Type { get; } + /// The connection URL to be used for this service. + public string Target { get; } + /// Whether the connection is tagged as the default connection of its type. + public bool IsDefault { get; } + /// + /// The credentials used by the connection + /// 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 BaseCredentials Credentials { get; } + /// Metadata of the connection. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.Serialization.cs deleted file mode 100644 index 8813334bbd2a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownInternalConnectionProperties))] - public partial class ConnectionProperties : 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(ConnectionProperties)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("authType"u8); - writer.WriteStringValue(AuthType.ToSerialString()); - writer.WritePropertyName("category"u8); - writer.WriteStringValue(Category.ToString()); - writer.WritePropertyName("target"u8); - writer.WriteStringValue(Target); - 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 - } - } - } - - ConnectionProperties 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(ConnectionProperties)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeConnectionProperties(document.RootElement, options); - } - - internal static ConnectionProperties DeserializeConnectionProperties(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("authType", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "AAD": return InternalConnectionPropertiesAADAuth.DeserializeInternalConnectionPropertiesAADAuth(element, options); - case "ApiKey": return ConnectionPropertiesApiKeyAuth.DeserializeConnectionPropertiesApiKeyAuth(element, options); - case "CustomKeys": return InternalConnectionPropertiesCustomAuth.DeserializeInternalConnectionPropertiesCustomAuth(element, options); - case "None": return InternalConnectionPropertiesNoAuth.DeserializeInternalConnectionPropertiesNoAuth(element, options); - case "SAS": return InternalConnectionPropertiesSASAuth.DeserializeInternalConnectionPropertiesSASAuth(element, options); - } - } - return UnknownInternalConnectionProperties.DeserializeUnknownInternalConnectionProperties(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ConnectionProperties)} does not support writing '{options.Format}' format."); - } - } - - ConnectionProperties 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 DeserializeConnectionProperties(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ConnectionProperties)} 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 ConnectionProperties FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeConnectionProperties(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/ConnectionProperties.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.cs deleted file mode 100644 index f8422e640716..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// Connection properties - /// 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 ConnectionProperties - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// is null. - protected ConnectionProperties(ConnectionType category, string target) - { - Argument.AssertNotNull(target, nameof(target)); - - Category = category; - Target = target; - } - - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// Category of the connection. - /// The connection URL to be used for this service. - /// Keeps track of any properties unknown to the library. - internal ConnectionProperties(AuthenticationType authType, ConnectionType category, string target, IDictionary serializedAdditionalRawData) - { - AuthType = authType; - Category = category; - Target = target; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ConnectionProperties() - { - } - /// Category of the connection. - public ConnectionType Category { get; } - /// The connection URL to be used for this service. - public string Target { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.Serialization.cs deleted file mode 100644 index 1b95023b1830..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.Serialization.cs +++ /dev/null @@ -1,146 +0,0 @@ -// 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 ConnectionPropertiesApiKeyAuth : 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(ConnectionPropertiesApiKeyAuth)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("credentials"u8); - writer.WriteObjectValue(Credentials, options); - } - - ConnectionPropertiesApiKeyAuth 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(ConnectionPropertiesApiKeyAuth)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeConnectionPropertiesApiKeyAuth(document.RootElement, options); - } - - internal static ConnectionPropertiesApiKeyAuth DeserializeConnectionPropertiesApiKeyAuth(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - CredentialsApiKeyAuth credentials = default; - AuthenticationType authType = default; - ConnectionType category = default; - string target = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("credentials"u8)) - { - credentials = CredentialsApiKeyAuth.DeserializeCredentialsApiKeyAuth(property.Value, options); - continue; - } - if (property.NameEquals("authType"u8)) - { - authType = property.Value.GetString().ToAuthenticationType(); - continue; - } - if (property.NameEquals("category"u8)) - { - category = new ConnectionType(property.Value.GetString()); - continue; - } - if (property.NameEquals("target"u8)) - { - target = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ConnectionPropertiesApiKeyAuth(authType, category, target, serializedAdditionalRawData, credentials); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ConnectionPropertiesApiKeyAuth)} does not support writing '{options.Format}' format."); - } - } - - ConnectionPropertiesApiKeyAuth 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 DeserializeConnectionPropertiesApiKeyAuth(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ConnectionPropertiesApiKeyAuth)} 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 ConnectionPropertiesApiKeyAuth FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeConnectionPropertiesApiKeyAuth(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/ConnectionPropertiesApiKeyAuth.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.cs deleted file mode 100644 index 744b4576f2e1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Connection properties for connections with API key authentication. - public partial class ConnectionPropertiesApiKeyAuth : ConnectionProperties - { - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// Credentials will only be present for authType=ApiKey. - /// or is null. - internal ConnectionPropertiesApiKeyAuth(ConnectionType category, string target, CredentialsApiKeyAuth credentials) : base(category, target) - { - Argument.AssertNotNull(target, nameof(target)); - Argument.AssertNotNull(credentials, nameof(credentials)); - - AuthType = AuthenticationType.ApiKey; - Credentials = credentials; - } - - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// Category of the connection. - /// The connection URL to be used for this service. - /// Keeps track of any properties unknown to the library. - /// Credentials will only be present for authType=ApiKey. - internal ConnectionPropertiesApiKeyAuth(AuthenticationType authType, ConnectionType category, string target, IDictionary serializedAdditionalRawData, CredentialsApiKeyAuth credentials) : base(authType, category, target, serializedAdditionalRawData) - { - Credentials = credentials; - } - - /// Initializes a new instance of for deserialization. - internal ConnectionPropertiesApiKeyAuth() - { - } - - /// Credentials will only be present for authType=ApiKey. - public CredentialsApiKeyAuth Credentials { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionResponse.cs deleted file mode 100644 index af78c22e4c85..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionResponse.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Response from the listSecrets operation. - public partial class ConnectionResponse - { - /// - /// 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 unique identifier for the connection. - /// The name of the resource. - /// - /// The properties of the resource - /// 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 . - /// - /// , or is null. - internal ConnectionResponse(string id, string name, ConnectionProperties properties) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(properties, nameof(properties)); - - Id = id; - Name = name; - Properties = properties; - } - - /// Initializes a new instance of . - /// A unique identifier for the connection. - /// The name of the resource. - /// - /// The properties of the resource - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal ConnectionResponse(string id, string name, ConnectionProperties properties, IDictionary serializedAdditionalRawData) - { - Id = id; - Name = name; - Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ConnectionResponse() - { - } - - /// A unique identifier for the connection. - public string Id { get; } - /// The name of the resource. - public string Name { get; } - /// - /// The properties of the resource - /// 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 ConnectionProperties Properties { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs index 8c7c10020180..5c1f164e4939 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs @@ -23,30 +23,33 @@ public ConnectionType(string value) } private const string AzureOpenAIValue = "AzureOpenAI"; - private const string ServerlessValue = "Serverless"; private const string AzureBlobStorageValue = "AzureBlob"; - private const string AzureAIServicesValue = "AIServices"; + private const string AzureStorageAccountValue = "AzureStorageAccount"; private const string AzureAISearchValue = "CognitiveSearch"; + private const string CosmosDBValue = "CosmosDB"; private const string APIKeyValue = "ApiKey"; + private const string ApplicationConfigurationValue = "AppConfig"; + private const string ApplicationInsightsValue = "AppInsights"; private const string CustomValue = "CustomKeys"; - private const string CognitiveServiceValue = "CognitiveService"; /// Azure OpenAI Service. public static ConnectionType AzureOpenAI { get; } = new ConnectionType(AzureOpenAIValue); - /// Serverless API Service. - public static ConnectionType Serverless { get; } = new ConnectionType(ServerlessValue); - /// Azure Blob Storage. + /// Azure Blob Storage, with specified container. public static ConnectionType AzureBlobStorage { get; } = new ConnectionType(AzureBlobStorageValue); - /// Azure AI Services. - public static ConnectionType AzureAIServices { get; } = new ConnectionType(AzureAIServicesValue); + /// Azure Blob Storage, with container not specified (used by Agents). + public static ConnectionType AzureStorageAccount { get; } = new ConnectionType(AzureStorageAccountValue); /// Azure AI Search. public static ConnectionType AzureAISearch { get; } = new ConnectionType(AzureAISearchValue); + /// CosmosDB. + public static ConnectionType CosmosDB { get; } = new ConnectionType(CosmosDBValue); /// Generic connection that uses API Key authentication. public static ConnectionType APIKey { get; } = new ConnectionType(APIKeyValue); - /// Generic connection that uses Custom authentication. + /// Application Configuration. + public static ConnectionType ApplicationConfiguration { get; } = new ConnectionType(ApplicationConfigurationValue); + /// Application Insights. + public static ConnectionType ApplicationInsights { get; } = new ConnectionType(ApplicationInsightsValue); + /// Custom Keys. public static ConnectionType Custom { get; } = new ConnectionType(CustomValue); - /// Cognitive Service. - public static ConnectionType CognitiveService { get; } = new ConnectionType(CognitiveServiceValue); /// Determines if two values are the same. public static bool operator ==(ConnectionType left, ConnectionType right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionsClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionsClient.cs index a00d9049ec36..da79bcced42d 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionsClient.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionsClient.cs @@ -6,9 +6,9 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Autorest.CSharp.Core; using Azure.Core; using Azure.Core.Pipeline; @@ -18,13 +18,10 @@ namespace Azure.AI.Projects /// The Connections sub-client. public partial class ConnectionsClient { - private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com/.default" }; + private static readonly string[] AuthorizationScopes = new string[] { "https://ai.azure.com/.default" }; private readonly TokenCredential _tokenCredential; private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; - private readonly string _subscriptionId; - private readonly string _resourceGroupName; - private readonly string _projectName; private readonly string _apiVersion; /// The ClientDiagnostics is used to provide tracing support for the client library. @@ -38,6 +35,265 @@ protected ConnectionsClient() { } + /// Initializes a new instance of ConnectionsClient. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// + /// The API version to use for this operation. + internal ConnectionsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get a connection by name, with its connection credentials. + /// The friendly name of the connection, provided by the user. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> GetWithCredentialsAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetWithCredentialsAsync(name, context).ConfigureAwait(false); + return Response.FromValue(Connection.FromResponse(response), response); + } + + /// Get a connection by name, with its connection credentials. + /// The friendly name of the connection, provided by the user. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response GetWithCredentials(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetWithCredentials(name, context); + return Response.FromValue(Connection.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get a connection by name, with its connection credentials + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The friendly name of the connection, provided by the user. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task GetWithCredentialsAsync(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("ConnectionsClient.GetWithCredentials"); + scope.Start(); + try + { + using HttpMessage message = CreateGetWithCredentialsRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get a connection by name, with its connection credentials + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The friendly name of the connection, provided by the user. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response GetWithCredentials(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("ConnectionsClient.GetWithCredentials"); + scope.Start(); + try + { + using HttpMessage message = CreateGetWithCredentialsRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List all connections in the project, without populating connection credentials. + /// List connections of this specific type. + /// List connections that are default connections. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetConnectionsAsync(ConnectionType? connectionType = null, bool? defaultConnection = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConnectionsRequest(connectionType?.ToString(), defaultConnection, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConnectionsNextPageRequest(nextLink, connectionType?.ToString(), defaultConnection, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Connection.DeserializeConnection(e), ClientDiagnostics, _pipeline, "ConnectionsClient.GetConnections", "value", "nextLink", context); + } + + /// List all connections in the project, without populating connection credentials. + /// List connections of this specific type. + /// List connections that are default connections. + /// The cancellation token to use. + /// + public virtual Pageable GetConnections(ConnectionType? connectionType = null, bool? defaultConnection = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConnectionsRequest(connectionType?.ToString(), defaultConnection, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConnectionsNextPageRequest(nextLink, connectionType?.ToString(), defaultConnection, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Connection.DeserializeConnection(e), ClientDiagnostics, _pipeline, "ConnectionsClient.GetConnections", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all connections in the project, without populating connection credentials + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// List connections of this specific type. Allowed values: "AzureOpenAI" | "AzureBlob" | "AzureStorageAccount" | "CognitiveSearch" | "CosmosDB" | "ApiKey" | "AppConfig" | "AppInsights" | "CustomKeys". + /// List connections that are default connections. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetConnectionsAsync(string connectionType, bool? defaultConnection, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConnectionsRequest(connectionType, defaultConnection, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConnectionsNextPageRequest(nextLink, connectionType, defaultConnection, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ConnectionsClient.GetConnections", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all connections in the project, without populating connection credentials + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// List connections of this specific type. Allowed values: "AzureOpenAI" | "AzureBlob" | "AzureStorageAccount" | "CognitiveSearch" | "CosmosDB" | "ApiKey" | "AppConfig" | "AppInsights" | "CustomKeys". + /// List connections that are default connections. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetConnections(string connectionType, bool? defaultConnection, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConnectionsRequest(connectionType, defaultConnection, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConnectionsNextPageRequest(nextLink, connectionType, defaultConnection, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ConnectionsClient.GetConnections", "value", "nextLink", context); + } + + internal HttpMessage CreateGetWithCredentialsRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/connections/", false); + uri.AppendPath(name, true); + uri.AppendPath("/getConnectionWithCredentials", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetConnectionsRequest(string connectionType, bool? defaultConnection, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/connections", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (connectionType != null) + { + uri.AppendQuery("connectionType", connectionType, true); + } + if (defaultConnection != null) + { + uri.AppendQuery("defaultConnection", defaultConnection.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetConnectionsNextPageRequest(string nextLink, string connectionType, bool? defaultConnection, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + private static RequestContext DefaultRequestContext = new RequestContext(); internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) { diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CosmosDBIndex.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CosmosDBIndex.Serialization.cs new file mode 100644 index 000000000000..840aed1e2fb4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CosmosDBIndex.Serialization.cs @@ -0,0 +1,217 @@ +// 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 CosmosDBIndex : 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(CosmosDBIndex)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + writer.WritePropertyName("databaseName"u8); + writer.WriteStringValue(DatabaseName); + writer.WritePropertyName("containerName"u8); + writer.WriteStringValue(ContainerName); + writer.WritePropertyName("embeddingConfiguration"u8); + writer.WriteObjectValue(EmbeddingConfiguration, options); + writer.WritePropertyName("fieldMapping"u8); + writer.WriteObjectValue(FieldMapping, options); + } + + CosmosDBIndex 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(CosmosDBIndex)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCosmosDBIndex(document.RootElement, options); + } + + internal static CosmosDBIndex DeserializeCosmosDBIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionName = default; + string databaseName = default; + string containerName = default; + EmbeddingConfiguration embeddingConfiguration = default; + FieldMapping fieldMapping = default; + IndexType type = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("databaseName"u8)) + { + databaseName = property.Value.GetString(); + continue; + } + if (property.NameEquals("containerName"u8)) + { + containerName = property.Value.GetString(); + continue; + } + if (property.NameEquals("embeddingConfiguration"u8)) + { + embeddingConfiguration = EmbeddingConfiguration.DeserializeEmbeddingConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("fieldMapping"u8)) + { + fieldMapping = FieldMapping.DeserializeFieldMapping(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new IndexType(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CosmosDBIndex( + type, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData, + connectionName, + databaseName, + containerName, + embeddingConfiguration, + fieldMapping); + } + + 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, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(CosmosDBIndex)} does not support writing '{options.Format}' format."); + } + } + + CosmosDBIndex 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 DeserializeCosmosDBIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CosmosDBIndex)} 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 CosmosDBIndex FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCosmosDBIndex(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/CosmosDBIndex.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CosmosDBIndex.cs new file mode 100644 index 000000000000..b2a0b6b84fe6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CosmosDBIndex.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// CosmosDB Vector Store Index Definition. + public partial class CosmosDBIndex : Index + { + /// Initializes a new instance of . + /// Name of connection to CosmosDB. + /// Name of the CosmosDB Database. + /// Name of CosmosDB Container. + /// Embedding model configuration. + /// Field mapping configuration. + /// , , , or is null. + public CosmosDBIndex(string connectionName, string databaseName, string containerName, EmbeddingConfiguration embeddingConfiguration, FieldMapping fieldMapping) + { + Argument.AssertNotNull(connectionName, nameof(connectionName)); + Argument.AssertNotNull(databaseName, nameof(databaseName)); + Argument.AssertNotNull(containerName, nameof(containerName)); + Argument.AssertNotNull(embeddingConfiguration, nameof(embeddingConfiguration)); + Argument.AssertNotNull(fieldMapping, nameof(fieldMapping)); + + Type = IndexType.CosmosDB; + ConnectionName = connectionName; + DatabaseName = databaseName; + ContainerName = containerName; + EmbeddingConfiguration = embeddingConfiguration; + FieldMapping = fieldMapping; + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + /// Name of connection to CosmosDB. + /// Name of the CosmosDB Database. + /// Name of CosmosDB Container. + /// Embedding model configuration. + /// Field mapping configuration. + internal CosmosDBIndex(IndexType type, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData, string connectionName, string databaseName, string containerName, EmbeddingConfiguration embeddingConfiguration, FieldMapping fieldMapping) : base(type, id, name, version, description, tags, serializedAdditionalRawData) + { + ConnectionName = connectionName; + DatabaseName = databaseName; + ContainerName = containerName; + EmbeddingConfiguration = embeddingConfiguration; + FieldMapping = fieldMapping; + } + + /// Initializes a new instance of for deserialization. + internal CosmosDBIndex() + { + } + + /// Name of connection to CosmosDB. + public string ConnectionName { get; set; } + /// Name of the CosmosDB Database. + public string DatabaseName { get; set; } + /// Name of CosmosDB Container. + public string ContainerName { get; set; } + /// Embedding model configuration. + public EmbeddingConfiguration EmbeddingConfiguration { get; set; } + /// Field mapping configuration. + public FieldMapping FieldMapping { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.Serialization.cs deleted file mode 100644 index dce8765f7a1d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.Serialization.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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 -{ - internal partial class CreateAgentRequest : 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(CreateAgentRequest)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); - if (Optional.IsDefined(Name)) - { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } - } - if (Optional.IsDefined(Description)) - { - if (Description != null) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - else - { - writer.WriteNull("description"); - } - } - if (Optional.IsDefined(Instructions)) - { - if (Instructions != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); - } - else - { - writer.WriteNull("instructions"); - } - } - if (Optional.IsCollectionDefined(Tools)) - { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(ToolResources)) - { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } - } - if (Optional.IsDefined(Temperature)) - { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } - } - if (Optional.IsDefined(TopP)) - { - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } - } - if (Optional.IsDefined(ResponseFormat)) - { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ResponseFormat); -#else - using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("response_format"); - } - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - CreateAgentRequest 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(CreateAgentRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateAgentRequest(document.RootElement, options); - } - - internal static CreateAgentRequest DeserializeCreateAgentRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string model = default; - string name = default; - string description = default; - string instructions = default; - IReadOnlyList tools = default; - ToolResources toolResources = default; - float? temperature = default; - float? topP = default; - BinaryData responseFormat = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("description"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - description = null; - continue; - } - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("instructions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); - continue; - } - if (property.NameEquals("tools"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; - } - if (property.NameEquals("tool_resources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = ToolResources.DeserializeToolResources(property.Value, options); - continue; - } - if (property.NameEquals("temperature"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("top_p"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("response_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CreateAgentRequest( - model, - name, - description, - instructions, - tools ?? new ChangeTrackingList(), - toolResources, - temperature, - topP, - responseFormat, - metadata ?? new ChangeTrackingDictionary(), - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CreateAgentRequest)} does not support writing '{options.Format}' format."); - } - } - - CreateAgentRequest 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 DeserializeCreateAgentRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CreateAgentRequest)} 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 CreateAgentRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCreateAgentRequest(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/CreateAgentRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.cs deleted file mode 100644 index 47194c5840d6..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.cs +++ /dev/null @@ -1,189 +0,0 @@ -// 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 CreateAgentRequest. - internal partial class CreateAgentRequest - { - /// - /// 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 ID of the model to use. - /// is null. - internal CreateAgentRequest(string model) - { - Argument.AssertNotNull(model, nameof(model)); - - Model = model; - Tools = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The ID of the model to use. - /// The name of the new agent. - /// The description of the new agent. - /// The system instructions for the new agent to use. - /// - /// 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 . - /// - /// - /// 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` - /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// The response format of the tool calls used by this agent. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal CreateAgentRequest(string model, string name, string description, string instructions, IReadOnlyList tools, ToolResources toolResources, float? temperature, float? topP, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Model = model; - Name = name; - Description = description; - Instructions = instructions; - Tools = tools; - ToolResources = toolResources; - Temperature = temperature; - TopP = topP; - ResponseFormat = responseFormat; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal CreateAgentRequest() - { - } - - /// The ID of the model to use. - public string Model { get; } - /// The name of the new agent. - public string Name { get; } - /// The description of the new agent. - public string Description { get; } - /// The system instructions for the new agent to use. - public string Instructions { get; } - /// - /// 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 . - /// - public IReadOnlyList Tools { get; } - /// - /// 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` - /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - public ToolResources ToolResources { get; } - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - public float? Temperature { get; } - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - public float? TopP { get; } - /// - /// The response format of the tool calls used by this agent. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ResponseFormat { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.Serialization.cs deleted file mode 100644 index c50fc9df5582..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.Serialization.cs +++ /dev/null @@ -1,222 +0,0 @@ -// 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 -{ - internal partial class CreateMessageRequest : 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(CreateMessageRequest)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToString()); - writer.WritePropertyName("content"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Content); -#else - using (JsonDocument document = JsonDocument.Parse(Content, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - if (Optional.IsCollectionDefined(Attachments)) - { - if (Attachments != null) - { - writer.WritePropertyName("attachments"u8); - writer.WriteStartArray(); - foreach (var item in Attachments) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("attachments"); - } - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - CreateMessageRequest 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(CreateMessageRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateMessageRequest(document.RootElement, options); - } - - internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageRole role = default; - BinaryData content = default; - IReadOnlyList attachments = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("role"u8)) - { - role = new MessageRole(property.Value.GetString()); - continue; - } - if (property.NameEquals("content"u8)) - { - content = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("attachments"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageAttachment.DeserializeMessageAttachment(item, options)); - } - attachments = array; - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CreateMessageRequest(role, content, attachments ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support writing '{options.Format}' format."); - } - } - - CreateMessageRequest 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 DeserializeCreateMessageRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CreateMessageRequest)} 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 CreateMessageRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCreateMessageRequest(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/CreateMessageRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.cs deleted file mode 100644 index 81df27722a94..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.cs +++ /dev/null @@ -1,159 +0,0 @@ -// 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 CreateMessageRequest. - internal partial class CreateMessageRequest - { - /// - /// 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 role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). - /// - /// is null. - internal CreateMessageRequest(MessageRole role, BinaryData content) - { - Argument.AssertNotNull(content, nameof(content)); - - Role = role; - Content = content; - Attachments = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// - /// The role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). - /// - /// A list of files attached to the message, and the tools they should be added to. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal CreateMessageRequest(MessageRole role, BinaryData content, IReadOnlyList attachments, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Role = role; - Content = content; - Attachments = attachments; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal CreateMessageRequest() - { - } - - /// - /// The role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - public MessageRole Role { get; } - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// where T is of type - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Content { get; } - /// A list of files attached to the message, and the tools they should be added to. - public IReadOnlyList Attachments { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.Serialization.cs deleted file mode 100644 index ec58e04ede93..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.Serialization.cs +++ /dev/null @@ -1,530 +0,0 @@ -// 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 -{ - internal partial class CreateRunRequest : 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(CreateRunRequest)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); - if (Optional.IsDefined(OverrideModelName)) - { - if (OverrideModelName != null) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(OverrideModelName); - } - else - { - writer.WriteNull("model"); - } - } - if (Optional.IsDefined(OverrideInstructions)) - { - if (OverrideInstructions != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(OverrideInstructions); - } - else - { - writer.WriteNull("instructions"); - } - } - if (Optional.IsDefined(AdditionalInstructions)) - { - if (AdditionalInstructions != null) - { - writer.WritePropertyName("additional_instructions"u8); - writer.WriteStringValue(AdditionalInstructions); - } - else - { - writer.WriteNull("additional_instructions"); - } - } - if (Optional.IsCollectionDefined(AdditionalMessages)) - { - if (AdditionalMessages != null) - { - writer.WritePropertyName("additional_messages"u8); - writer.WriteStartArray(); - foreach (var item in AdditionalMessages) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("additional_messages"); - } - } - if (Optional.IsCollectionDefined(OverrideTools)) - { - if (OverrideTools != null) - { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in OverrideTools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("tools"); - } - } - if (Optional.IsDefined(Stream)) - { - writer.WritePropertyName("stream"u8); - writer.WriteBooleanValue(Stream.Value); - } - if (Optional.IsDefined(Temperature)) - { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } - } - if (Optional.IsDefined(TopP)) - { - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } - } - if (Optional.IsDefined(MaxPromptTokens)) - { - if (MaxPromptTokens != null) - { - writer.WritePropertyName("max_prompt_tokens"u8); - writer.WriteNumberValue(MaxPromptTokens.Value); - } - else - { - writer.WriteNull("max_prompt_tokens"); - } - } - if (Optional.IsDefined(MaxCompletionTokens)) - { - if (MaxCompletionTokens != null) - { - writer.WritePropertyName("max_completion_tokens"u8); - writer.WriteNumberValue(MaxCompletionTokens.Value); - } - else - { - writer.WriteNull("max_completion_tokens"); - } - } - if (Optional.IsDefined(TruncationStrategy)) - { - if (TruncationStrategy != null) - { - writer.WritePropertyName("truncation_strategy"u8); - writer.WriteObjectValue(TruncationStrategy, options); - } - else - { - writer.WriteNull("truncation_strategy"); - } - } - if (Optional.IsDefined(ToolChoice)) - { - if (ToolChoice != null) - { - writer.WritePropertyName("tool_choice"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ToolChoice); -#else - using (JsonDocument document = JsonDocument.Parse(ToolChoice, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("tool_choice"); - } - } - if (Optional.IsDefined(ResponseFormat)) - { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ResponseFormat); -#else - using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("response_format"); - } - } - if (Optional.IsDefined(ParallelToolCalls)) - { - writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(ParallelToolCalls.Value); - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - CreateRunRequest 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(CreateRunRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateRunRequest(document.RootElement, options); - } - - internal static CreateRunRequest DeserializeCreateRunRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string assistantId = default; - string model = default; - string instructions = default; - string additionalInstructions = default; - IReadOnlyList additionalMessages = default; - IReadOnlyList tools = default; - bool? stream = default; - float? temperature = default; - float? topP = default; - int? maxPromptTokens = default; - int? maxCompletionTokens = default; - TruncationObject truncationStrategy = default; - BinaryData toolChoice = default; - BinaryData responseFormat = default; - bool? parallelToolCalls = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("assistant_id"u8)) - { - assistantId = property.Value.GetString(); - continue; - } - if (property.NameEquals("model"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - model = null; - continue; - } - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("instructions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); - continue; - } - if (property.NameEquals("additional_instructions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - additionalInstructions = null; - continue; - } - additionalInstructions = property.Value.GetString(); - continue; - } - if (property.NameEquals("additional_messages"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ThreadMessageOptions.DeserializeThreadMessageOptions(item, options)); - } - additionalMessages = array; - continue; - } - if (property.NameEquals("tools"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; - } - if (property.NameEquals("stream"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - stream = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("temperature"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("top_p"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("max_prompt_tokens"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxPromptTokens = null; - continue; - } - maxPromptTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("max_completion_tokens"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxCompletionTokens = null; - continue; - } - maxCompletionTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("truncation_strategy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - truncationStrategy = null; - continue; - } - truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); - continue; - } - if (property.NameEquals("tool_choice"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolChoice = null; - continue; - } - toolChoice = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("response_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("parallel_tool_calls"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - parallelToolCalls = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CreateRunRequest( - assistantId, - model, - instructions, - additionalInstructions, - additionalMessages ?? new ChangeTrackingList(), - tools ?? new ChangeTrackingList(), - stream, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - responseFormat, - parallelToolCalls, - metadata ?? new ChangeTrackingDictionary(), - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CreateRunRequest)} does not support writing '{options.Format}' format."); - } - } - - CreateRunRequest 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 DeserializeCreateRunRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CreateRunRequest)} 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 CreateRunRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCreateRunRequest(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/CreateRunRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.cs deleted file mode 100644 index f7e4f5948cb5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.cs +++ /dev/null @@ -1,281 +0,0 @@ -// 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 CreateRunRequest. - internal partial class CreateRunRequest - { - /// - /// 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 ID of the agent that should run the thread. - /// is null. - internal CreateRunRequest(string assistantId) - { - Argument.AssertNotNull(assistantId, nameof(assistantId)); - - AssistantId = assistantId; - AdditionalMessages = new ChangeTrackingList(); - OverrideTools = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The ID of the agent that should run the thread. - /// The overridden model name that the agent should use to run the thread. - /// The overridden system instructions that the agent should use to run the thread. - /// - /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior - /// on a per-run basis without overriding other instructions. - /// - /// Adds additional messages to the thread before creating the run. - /// - /// 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 . - /// - /// - /// If `true`, returns a stream of events that happen during the Run as server-sent events, - /// terminating when the Run enters a terminal state with a `data: [DONE]` message. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - /// more random, while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model - /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - /// comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// - /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - /// the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// - /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort - /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of - /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// The strategy to use for dropping messages as the context windows moves forward. - /// Controls whether or not and which tool is called by the model. - /// Specifies the format that the model must output. - /// If `true` functions will run in parallel during tool use. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal CreateRunRequest(string assistantId, string overrideModelName, string overrideInstructions, string additionalInstructions, IReadOnlyList additionalMessages, IReadOnlyList overrideTools, bool? stream, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, bool? parallelToolCalls, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - AssistantId = assistantId; - OverrideModelName = overrideModelName; - OverrideInstructions = overrideInstructions; - AdditionalInstructions = additionalInstructions; - AdditionalMessages = additionalMessages; - OverrideTools = overrideTools; - Stream = stream; - Temperature = temperature; - TopP = topP; - MaxPromptTokens = maxPromptTokens; - MaxCompletionTokens = maxCompletionTokens; - TruncationStrategy = truncationStrategy; - ToolChoice = toolChoice; - ResponseFormat = responseFormat; - ParallelToolCalls = parallelToolCalls; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal CreateRunRequest() - { - } - - /// The ID of the agent that should run the thread. - public string AssistantId { get; } - /// The overridden model name that the agent should use to run the thread. - public string OverrideModelName { get; } - /// The overridden system instructions that the agent should use to run the thread. - public string OverrideInstructions { get; } - /// - /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior - /// on a per-run basis without overriding other instructions. - /// - public string AdditionalInstructions { get; } - /// Adds additional messages to the thread before creating the run. - public IReadOnlyList AdditionalMessages { get; } - /// - /// 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 . - /// - public IReadOnlyList OverrideTools { get; } - /// - /// If `true`, returns a stream of events that happen during the Run as server-sent events, - /// terminating when the Run enters a terminal state with a `data: [DONE]` message. - /// - public bool? Stream { get; } - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - /// more random, while lower values like 0.2 will make it more focused and deterministic. - /// - public float? Temperature { get; } - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model - /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - /// comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - public float? TopP { get; } - /// - /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - /// the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - public int? MaxPromptTokens { get; } - /// - /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort - /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of - /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - public int? MaxCompletionTokens { get; } - /// The strategy to use for dropping messages as the context windows moves forward. - public TruncationObject TruncationStrategy { get; } - /// - /// Controls whether or not and which tool is called by the model. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ToolChoice { get; } - /// - /// Specifies the format that the model must output. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ResponseFormat { get; } - /// If `true` functions will run in parallel during tool use. - public bool? ParallelToolCalls { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.Serialization.cs deleted file mode 100644 index 290df018f171..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.Serialization.cs +++ /dev/null @@ -1,513 +0,0 @@ -// 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 -{ - internal partial class CreateThreadAndRunRequest : 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(CreateThreadAndRunRequest)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); - if (Optional.IsDefined(Thread)) - { - writer.WritePropertyName("thread"u8); - writer.WriteObjectValue(Thread, options); - } - if (Optional.IsDefined(OverrideModelName)) - { - if (OverrideModelName != null) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(OverrideModelName); - } - else - { - writer.WriteNull("model"); - } - } - if (Optional.IsDefined(OverrideInstructions)) - { - if (OverrideInstructions != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(OverrideInstructions); - } - else - { - writer.WriteNull("instructions"); - } - } - if (Optional.IsCollectionDefined(OverrideTools)) - { - if (OverrideTools != null) - { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in OverrideTools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("tools"); - } - } - if (Optional.IsDefined(ToolResources)) - { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } - } - if (Optional.IsDefined(Stream)) - { - writer.WritePropertyName("stream"u8); - writer.WriteBooleanValue(Stream.Value); - } - if (Optional.IsDefined(Temperature)) - { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } - } - if (Optional.IsDefined(TopP)) - { - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } - } - if (Optional.IsDefined(MaxPromptTokens)) - { - if (MaxPromptTokens != null) - { - writer.WritePropertyName("max_prompt_tokens"u8); - writer.WriteNumberValue(MaxPromptTokens.Value); - } - else - { - writer.WriteNull("max_prompt_tokens"); - } - } - if (Optional.IsDefined(MaxCompletionTokens)) - { - if (MaxCompletionTokens != null) - { - writer.WritePropertyName("max_completion_tokens"u8); - writer.WriteNumberValue(MaxCompletionTokens.Value); - } - else - { - writer.WriteNull("max_completion_tokens"); - } - } - if (Optional.IsDefined(TruncationStrategy)) - { - if (TruncationStrategy != null) - { - writer.WritePropertyName("truncation_strategy"u8); - writer.WriteObjectValue(TruncationStrategy, options); - } - else - { - writer.WriteNull("truncation_strategy"); - } - } - if (Optional.IsDefined(ToolChoice)) - { - if (ToolChoice != null) - { - writer.WritePropertyName("tool_choice"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ToolChoice); -#else - using (JsonDocument document = JsonDocument.Parse(ToolChoice, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("tool_choice"); - } - } - if (Optional.IsDefined(ResponseFormat)) - { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ResponseFormat); -#else - using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("response_format"); - } - } - if (Optional.IsDefined(ParallelToolCalls)) - { - writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(ParallelToolCalls.Value); - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - CreateThreadAndRunRequest 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(CreateThreadAndRunRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateThreadAndRunRequest(document.RootElement, options); - } - - internal static CreateThreadAndRunRequest DeserializeCreateThreadAndRunRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string assistantId = default; - AgentThreadCreationOptions thread = default; - string model = default; - string instructions = default; - IReadOnlyList tools = default; - UpdateToolResourcesOptions toolResources = default; - bool? stream = default; - float? temperature = default; - float? topP = default; - int? maxPromptTokens = default; - int? maxCompletionTokens = default; - TruncationObject truncationStrategy = default; - BinaryData toolChoice = default; - BinaryData responseFormat = default; - bool? parallelToolCalls = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("assistant_id"u8)) - { - assistantId = property.Value.GetString(); - continue; - } - if (property.NameEquals("thread"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - thread = AgentThreadCreationOptions.DeserializeAgentThreadCreationOptions(property.Value, options); - continue; - } - if (property.NameEquals("model"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - model = null; - continue; - } - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("instructions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); - continue; - } - if (property.NameEquals("tools"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; - } - if (property.NameEquals("tool_resources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = UpdateToolResourcesOptions.DeserializeUpdateToolResourcesOptions(property.Value, options); - continue; - } - if (property.NameEquals("stream"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - stream = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("temperature"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("top_p"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("max_prompt_tokens"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxPromptTokens = null; - continue; - } - maxPromptTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("max_completion_tokens"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxCompletionTokens = null; - continue; - } - maxCompletionTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("truncation_strategy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - truncationStrategy = null; - continue; - } - truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); - continue; - } - if (property.NameEquals("tool_choice"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolChoice = null; - continue; - } - toolChoice = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("response_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("parallel_tool_calls"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - parallelToolCalls = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CreateThreadAndRunRequest( - assistantId, - thread, - model, - instructions, - tools ?? new ChangeTrackingList(), - toolResources, - stream, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - responseFormat, - parallelToolCalls, - metadata ?? new ChangeTrackingDictionary(), - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CreateThreadAndRunRequest)} does not support writing '{options.Format}' format."); - } - } - - CreateThreadAndRunRequest 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 DeserializeCreateThreadAndRunRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CreateThreadAndRunRequest)} 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 CreateThreadAndRunRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCreateThreadAndRunRequest(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/CreateThreadAndRunRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.cs deleted file mode 100644 index d545c5ebca77..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.cs +++ /dev/null @@ -1,274 +0,0 @@ -// 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 CreateThreadAndRunRequest. - internal partial class CreateThreadAndRunRequest - { - /// - /// 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 ID of the agent for which the thread should be created. - /// is null. - internal CreateThreadAndRunRequest(string assistantId) - { - Argument.AssertNotNull(assistantId, nameof(assistantId)); - - AssistantId = assistantId; - OverrideTools = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The ID of the agent for which the thread should be created. - /// The details used to create the new thread. If no thread is provided, an empty one will be created. - /// The overridden model that the agent should use to run the thread. - /// The overridden system instructions the agent should use to run the thread. - /// - /// 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 . - /// - /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. - /// - /// If `true`, returns a stream of events that happen during the Run as server-sent events, - /// terminating when the Run enters a terminal state with a `data: [DONE]` message. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - /// more random, while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model - /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - /// comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// - /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - /// the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// - /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens - /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - /// The strategy to use for dropping messages as the context windows moves forward. - /// Controls whether or not and which tool is called by the model. - /// Specifies the format that the model must output. - /// If `true` functions will run in parallel during tool use. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal CreateThreadAndRunRequest(string assistantId, AgentThreadCreationOptions thread, string overrideModelName, string overrideInstructions, IReadOnlyList overrideTools, UpdateToolResourcesOptions toolResources, bool? stream, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, bool? parallelToolCalls, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - AssistantId = assistantId; - Thread = thread; - OverrideModelName = overrideModelName; - OverrideInstructions = overrideInstructions; - OverrideTools = overrideTools; - ToolResources = toolResources; - Stream = stream; - Temperature = temperature; - TopP = topP; - MaxPromptTokens = maxPromptTokens; - MaxCompletionTokens = maxCompletionTokens; - TruncationStrategy = truncationStrategy; - ToolChoice = toolChoice; - ResponseFormat = responseFormat; - ParallelToolCalls = parallelToolCalls; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal CreateThreadAndRunRequest() - { - } - - /// The ID of the agent for which the thread should be created. - public string AssistantId { get; } - /// The details used to create the new thread. If no thread is provided, an empty one will be created. - public AgentThreadCreationOptions Thread { get; } - /// The overridden model that the agent should use to run the thread. - public string OverrideModelName { get; } - /// The overridden system instructions the agent should use to run the thread. - public string OverrideInstructions { get; } - /// - /// 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 . - /// - 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. - public UpdateToolResourcesOptions ToolResources { get; } - /// - /// If `true`, returns a stream of events that happen during the Run as server-sent events, - /// terminating when the Run enters a terminal state with a `data: [DONE]` message. - /// - public bool? Stream { get; } - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - /// more random, while lower values like 0.2 will make it more focused and deterministic. - /// - public float? Temperature { get; } - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model - /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - /// comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - public float? TopP { get; } - /// - /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - /// the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - public int? MaxPromptTokens { get; } - /// - /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only - /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens - /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - /// - public int? MaxCompletionTokens { get; } - /// The strategy to use for dropping messages as the context windows moves forward. - public TruncationObject TruncationStrategy { get; } - /// - /// Controls whether or not and which tool is called by the model. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ToolChoice { get; } - /// - /// Specifies the format that the model must output. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ResponseFormat { get; } - /// If `true` functions will run in parallel during tool use. - public bool? ParallelToolCalls { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadRequest.Serialization.cs deleted file mode 100644 index bd4367a1d496..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadRequest.Serialization.cs +++ /dev/null @@ -1,215 +0,0 @@ -// 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 -{ - internal partial class CreateThreadRequest : 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(CreateThreadRequest)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(Messages)) - { - writer.WritePropertyName("messages"u8); - writer.WriteStartArray(); - foreach (var item in Messages) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(ToolResources)) - { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - CreateThreadRequest 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(CreateThreadRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateThreadRequest(document.RootElement, options); - } - - internal static CreateThreadRequest DeserializeCreateThreadRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList messages = default; - ToolResources toolResources = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("messages"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ThreadMessageOptions.DeserializeThreadMessageOptions(item, options)); - } - messages = array; - continue; - } - if (property.NameEquals("tool_resources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = ToolResources.DeserializeToolResources(property.Value, options); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CreateThreadRequest(messages ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CreateThreadRequest)} does not support writing '{options.Format}' format."); - } - } - - CreateThreadRequest 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 DeserializeCreateThreadRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CreateThreadRequest)} 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 CreateThreadRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCreateThreadRequest(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/CreateThreadRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadRequest.cs deleted file mode 100644 index 786587e94f9b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadRequest.cs +++ /dev/null @@ -1,83 +0,0 @@ -// 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 CreateThreadRequest. - internal partial class CreateThreadRequest - { - /// - /// 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 . - internal CreateThreadRequest() - { - Messages = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The initial messages to associate with the new thread. - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs. - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal CreateThreadRequest(IReadOnlyList messages, ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Messages = messages; - ToolResources = toolResources; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The initial messages to associate with the new thread. - public IReadOnlyList Messages { get; } - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs. - /// - public ToolResources ToolResources { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs deleted file mode 100644 index 5501a5ce37f2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs +++ /dev/null @@ -1,199 +0,0 @@ -// 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 -{ - internal partial class CreateVectorStoreFileBatchRequest : 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(CreateVectorStoreFileBatchRequest)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(FileIds)) - { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(DataSources)) - { - writer.WritePropertyName("data_sources"u8); - writer.WriteStartArray(); - foreach (var item in DataSources) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(ChunkingStrategy)) - { - writer.WritePropertyName("chunking_strategy"u8); - writer.WriteObjectValue(ChunkingStrategy, options); - } - 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 - } - } - } - - CreateVectorStoreFileBatchRequest 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(CreateVectorStoreFileBatchRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateVectorStoreFileBatchRequest(document.RootElement, options); - } - - internal static CreateVectorStoreFileBatchRequest DeserializeCreateVectorStoreFileBatchRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList fileIds = default; - IReadOnlyList dataSources = default; - VectorStoreChunkingStrategyRequest chunkingStrategy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_ids"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; - continue; - } - if (property.NameEquals("data_sources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(VectorStoreDataSource.DeserializeVectorStoreDataSource(item, options)); - } - dataSources = array; - continue; - } - if (property.NameEquals("chunking_strategy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CreateVectorStoreFileBatchRequest(fileIds ?? new ChangeTrackingList(), dataSources ?? new ChangeTrackingList(), chunkingStrategy, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support writing '{options.Format}' format."); - } - } - - CreateVectorStoreFileBatchRequest 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 DeserializeCreateVectorStoreFileBatchRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} 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 CreateVectorStoreFileBatchRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCreateVectorStoreFileBatchRequest(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/CreateVectorStoreFileBatchRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileBatchRequest.cs deleted file mode 100644 index a206331985f4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileBatchRequest.cs +++ /dev/null @@ -1,83 +0,0 @@ -// 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 CreateVectorStoreFileBatchRequest. - internal partial class CreateVectorStoreFileBatchRequest - { - /// - /// 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 . - internal CreateVectorStoreFileBatchRequest() - { - FileIds = new ChangeTrackingList(); - DataSources = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// List of file identifiers. - /// List of Azure assets. - /// - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal CreateVectorStoreFileBatchRequest(IReadOnlyList fileIds, IReadOnlyList dataSources, VectorStoreChunkingStrategyRequest chunkingStrategy, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - DataSources = dataSources; - ChunkingStrategy = chunkingStrategy; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// List of file identifiers. - public IReadOnlyList FileIds { get; } - /// List of Azure assets. - public IReadOnlyList DataSources { get; } - /// - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. - /// 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 VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileRequest.Serialization.cs deleted file mode 100644 index e1cc32162dda..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileRequest.Serialization.cs +++ /dev/null @@ -1,175 +0,0 @@ -// 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 -{ - internal partial class CreateVectorStoreFileRequest : 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(CreateVectorStoreFileRequest)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (Optional.IsDefined(DataSource)) - { - writer.WritePropertyName("data_source"u8); - writer.WriteObjectValue(DataSource, options); - } - if (Optional.IsDefined(ChunkingStrategy)) - { - writer.WritePropertyName("chunking_strategy"u8); - writer.WriteObjectValue(ChunkingStrategy, options); - } - 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 - } - } - } - - CreateVectorStoreFileRequest 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(CreateVectorStoreFileRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateVectorStoreFileRequest(document.RootElement, options); - } - - internal static CreateVectorStoreFileRequest DeserializeCreateVectorStoreFileRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - VectorStoreDataSource dataSource = default; - VectorStoreChunkingStrategyRequest chunkingStrategy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("data_source"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - dataSource = VectorStoreDataSource.DeserializeVectorStoreDataSource(property.Value, options); - continue; - } - if (property.NameEquals("chunking_strategy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CreateVectorStoreFileRequest(fileId, dataSource, chunkingStrategy, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support writing '{options.Format}' format."); - } - } - - CreateVectorStoreFileRequest 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 DeserializeCreateVectorStoreFileRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} 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 CreateVectorStoreFileRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCreateVectorStoreFileRequest(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/CreateVectorStoreFileRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileRequest.cs deleted file mode 100644 index fba9287eb54a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreFileRequest.cs +++ /dev/null @@ -1,81 +0,0 @@ -// 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 CreateVectorStoreFileRequest. - internal partial class CreateVectorStoreFileRequest - { - /// - /// 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 . - internal CreateVectorStoreFileRequest() - { - } - - /// Initializes a new instance of . - /// Identifier of the file. - /// Azure asset ID. - /// - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal CreateVectorStoreFileRequest(string fileId, VectorStoreDataSource dataSource, VectorStoreChunkingStrategyRequest chunkingStrategy, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - DataSource = dataSource; - ChunkingStrategy = chunkingStrategy; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Identifier of the file. - public string FileId { get; } - /// Azure asset ID. - public VectorStoreDataSource DataSource { get; } - /// - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. - /// 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 VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreRequest.Serialization.cs deleted file mode 100644 index 0c9a16fdf47b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreRequest.Serialization.cs +++ /dev/null @@ -1,255 +0,0 @@ -// 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 -{ - internal partial class CreateVectorStoreRequest : 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(CreateVectorStoreRequest)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(FileIds)) - { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(StoreConfiguration)) - { - writer.WritePropertyName("configuration"u8); - writer.WriteObjectValue(StoreConfiguration, options); - } - if (Optional.IsDefined(ExpiresAfter)) - { - writer.WritePropertyName("expires_after"u8); - writer.WriteObjectValue(ExpiresAfter, options); - } - if (Optional.IsDefined(ChunkingStrategy)) - { - writer.WritePropertyName("chunking_strategy"u8); - writer.WriteObjectValue(ChunkingStrategy, options); - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - CreateVectorStoreRequest 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(CreateVectorStoreRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateVectorStoreRequest(document.RootElement, options); - } - - internal static CreateVectorStoreRequest DeserializeCreateVectorStoreRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList fileIds = default; - string name = default; - VectorStoreConfiguration configuration = default; - VectorStoreExpirationPolicy expiresAfter = default; - VectorStoreChunkingStrategyRequest chunkingStrategy = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_ids"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("configuration"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - configuration = VectorStoreConfiguration.DeserializeVectorStoreConfiguration(property.Value, options); - continue; - } - if (property.NameEquals("expires_after"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); - continue; - } - if (property.NameEquals("chunking_strategy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CreateVectorStoreRequest( - fileIds ?? new ChangeTrackingList(), - name, - configuration, - expiresAfter, - chunkingStrategy, - metadata ?? new ChangeTrackingDictionary(), - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CreateVectorStoreRequest)} does not support writing '{options.Format}' format."); - } - } - - CreateVectorStoreRequest 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 DeserializeCreateVectorStoreRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CreateVectorStoreRequest)} 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 CreateVectorStoreRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCreateVectorStoreRequest(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/CreateVectorStoreRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreRequest.cs deleted file mode 100644 index fe9accc379e2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateVectorStoreRequest.cs +++ /dev/null @@ -1,95 +0,0 @@ -// 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 CreateVectorStoreRequest. - internal partial class CreateVectorStoreRequest - { - /// - /// 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 . - internal CreateVectorStoreRequest() - { - FileIds = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. - /// The name of the vector store. - /// The vector store configuration, used when vector store is created from Azure asset URIs. - /// Details on when this vector store expires. - /// - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. - /// 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 . - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal CreateVectorStoreRequest(IReadOnlyList fileIds, string name, VectorStoreConfiguration storeConfiguration, VectorStoreExpirationPolicy expiresAfter, VectorStoreChunkingStrategyRequest chunkingStrategy, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - Name = name; - StoreConfiguration = storeConfiguration; - ExpiresAfter = expiresAfter; - ChunkingStrategy = chunkingStrategy; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. - public IReadOnlyList FileIds { get; } - /// The name of the vector store. - public string Name { get; } - /// The vector store configuration, used when vector store is created from Azure asset URIs. - public VectorStoreConfiguration StoreConfiguration { get; } - /// Details on when this vector store expires. - public VectorStoreExpirationPolicy ExpiresAfter { get; } - /// - /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. - /// 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 VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CredentialType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CredentialType.cs new file mode 100644 index 000000000000..b3c14abc3729 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CredentialType.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The credential type used by the connection. + internal readonly partial struct CredentialType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CredentialType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApiKeyValue = "ApiKey"; + private const string EntraIdValue = "AAD"; + private const string SASValue = "SAS"; + private const string CustomValue = "CustomKeys"; + private const string NoneValue = "None"; + + /// API Key credential. + public static CredentialType ApiKey { get; } = new CredentialType(ApiKeyValue); + /// Entra ID credential (formerly known as AAD). + public static CredentialType EntraId { get; } = new CredentialType(EntraIdValue); + /// Shared Access Signature (SAS) credential. + public static CredentialType SAS { get; } = new CredentialType(SASValue); + /// Custom credential. + public static CredentialType Custom { get; } = new CredentialType(CustomValue); + /// No credential. + public static CredentialType None { get; } = new CredentialType(NoneValue); + /// Determines if two values are the same. + public static bool operator ==(CredentialType left, CredentialType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CredentialType left, CredentialType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CredentialType(string value) => new CredentialType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CredentialType other && Equals(other); + /// + public bool Equals(CredentialType 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/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsApiKeyAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsApiKeyAuth.Serialization.cs deleted file mode 100644 index bdf0f358ef6d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsApiKeyAuth.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 CredentialsApiKeyAuth : 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(CredentialsApiKeyAuth)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("key"u8); - writer.WriteStringValue(Key); - 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 - } - } - } - - CredentialsApiKeyAuth 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(CredentialsApiKeyAuth)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCredentialsApiKeyAuth(document.RootElement, options); - } - - internal static CredentialsApiKeyAuth DeserializeCredentialsApiKeyAuth(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string key = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("key"u8)) - { - key = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CredentialsApiKeyAuth(key, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CredentialsApiKeyAuth)} does not support writing '{options.Format}' format."); - } - } - - CredentialsApiKeyAuth 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 DeserializeCredentialsApiKeyAuth(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CredentialsApiKeyAuth)} 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 CredentialsApiKeyAuth FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCredentialsApiKeyAuth(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/CredentialsApiKeyAuth.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsApiKeyAuth.cs deleted file mode 100644 index 97faa0c97097..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsApiKeyAuth.cs +++ /dev/null @@ -1,75 +0,0 @@ -// 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 credentials needed for API key authentication. - public partial class CredentialsApiKeyAuth - { - /// - /// 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 API key. - /// is null. - internal CredentialsApiKeyAuth(string key) - { - Argument.AssertNotNull(key, nameof(key)); - - Key = key; - } - - /// Initializes a new instance of . - /// The API key. - /// Keeps track of any properties unknown to the library. - internal CredentialsApiKeyAuth(string key, IDictionary serializedAdditionalRawData) - { - Key = key; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal CredentialsApiKeyAuth() - { - } - - /// The API key. - public string Key { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsSASAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsSASAuth.Serialization.cs deleted file mode 100644 index c79081df919f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsSASAuth.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 -{ - internal partial class CredentialsSASAuth : 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(CredentialsSASAuth)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("SAS"u8); - writer.WriteStringValue(SAS); - 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 - } - } - } - - CredentialsSASAuth 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(CredentialsSASAuth)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCredentialsSASAuth(document.RootElement, options); - } - - internal static CredentialsSASAuth DeserializeCredentialsSASAuth(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string sas = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("SAS"u8)) - { - sas = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CredentialsSASAuth(sas, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(CredentialsSASAuth)} does not support writing '{options.Format}' format."); - } - } - - CredentialsSASAuth 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 DeserializeCredentialsSASAuth(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CredentialsSASAuth)} 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 CredentialsSASAuth FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCredentialsSASAuth(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/CredentialsSASAuth.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsSASAuth.cs deleted file mode 100644 index 5bf56c6a308c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CredentialsSASAuth.cs +++ /dev/null @@ -1,75 +0,0 @@ -// 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 credentials needed for Shared Access Signatures (SAS) authentication. - internal partial class CredentialsSASAuth - { - /// - /// 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 Shared Access Signatures (SAS) token. - /// is null. - internal CredentialsSASAuth(string sas) - { - Argument.AssertNotNull(sas, nameof(sas)); - - SAS = sas; - } - - /// Initializes a new instance of . - /// The Shared Access Signatures (SAS) token. - /// Keeps track of any properties unknown to the library. - internal CredentialsSASAuth(string sas, IDictionary serializedAdditionalRawData) - { - SAS = sas; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal CredentialsSASAuth() - { - } - - /// The Shared Access Signatures (SAS) token. - public string SAS { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.cs deleted file mode 100644 index f8e54d767f1e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Cron Trigger Definition. - public partial class CronTrigger : Trigger - { - /// Initializes a new instance of . - /// Cron expression for the trigger. - /// is null. - public CronTrigger(string expression) - { - Argument.AssertNotNull(expression, nameof(expression)); - - Type = "Cron"; - Expression = expression; - } - - /// Initializes a new instance of . - /// Type of the trigger. - /// Keeps track of any properties unknown to the library. - /// Cron expression for the trigger. - internal CronTrigger(string type, IDictionary serializedAdditionalRawData, string expression) : base(type, serializedAdditionalRawData) - { - Expression = expression; - } - - /// Initializes a new instance of for deserialization. - internal CronTrigger() - { - } - - /// Cron expression for the trigger. - public string Expression { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CustomCredential.Serialization.cs similarity index 58% rename from sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredToolCall.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/CustomCredential.Serialization.cs index bc948c93155d..3ac16c3395ab 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredToolCall.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CustomCredential.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class UnknownRequiredToolCall : IUtf8JsonSerializable, IJsonModel + public partial class CustomCredential : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,28 +28,39 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RequiredToolCall)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(CustomCredential)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); + if (options.Format != "W") + { + writer.WritePropertyName("keys"u8); + writer.WriteStartObject(); + foreach (var item in Keys) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } } - RequiredToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + CustomCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RequiredToolCall)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(CustomCredential)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRequiredToolCall(document.RootElement, options); + return DeserializeCustomCredential(document.RootElement, options); } - internal static UnknownRequiredToolCall DeserializeUnknownRequiredToolCall(JsonElement element, ModelReaderWriterOptions options = null) + internal static CustomCredential DeserializeCustomCredential(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -57,20 +68,25 @@ internal static UnknownRequiredToolCall DeserializeUnknownRequiredToolCall(JsonE { return null; } - string id = default; - string type = "Unknown"; + IReadOnlyDictionary keys = default; + CredentialType type = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (property.NameEquals("keys"u8)) { - id = property.Value.GetString(); + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + keys = dictionary; continue; } if (property.NameEquals("type"u8)) { - type = property.Value.GetString(); + type = new CredentialType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -79,53 +95,53 @@ internal static UnknownRequiredToolCall DeserializeUnknownRequiredToolCall(JsonE } } serializedAdditionalRawData = rawDataDictionary; - return new UnknownRequiredToolCall(type, serializedAdditionalRawData, id); + return new CustomCredential(type, serializedAdditionalRawData, keys); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RequiredToolCall)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(CustomCredential)} does not support writing '{options.Format}' format."); } } - RequiredToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + CustomCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRequiredToolCall(document.RootElement, options); + return DeserializeCustomCredential(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RequiredToolCall)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(CustomCredential)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new UnknownRequiredToolCall FromResponse(Response response) + internal static new CustomCredential FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownRequiredToolCall(document.RootElement); + return DeserializeCustomCredential(document.RootElement); } /// Convert into a . internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CustomCredential.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CustomCredential.cs new file mode 100644 index 000000000000..f081ca86b583 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CustomCredential.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Custom credential definition. + public partial class CustomCredential : BaseCredentials + { + /// Initializes a new instance of . + internal CustomCredential() + { + Type = CredentialType.Custom; + Keys = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The type of credential used by the connection. + /// Keeps track of any properties unknown to the library. + /// The credential type. + internal CustomCredential(CredentialType type, IDictionary serializedAdditionalRawData, IReadOnlyDictionary keys) : base(type, serializedAdditionalRawData) + { + Keys = keys; + } + + /// The credential type. + public IReadOnlyDictionary Keys { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DatasetType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DatasetType.cs new file mode 100644 index 000000000000..a4629543310f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DatasetType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Enum to determine the type of data. + internal readonly partial struct DatasetType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DatasetType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UriFileValue = "uri_file"; + private const string UriFolderValue = "uri_folder"; + + /// URI file. + public static DatasetType UriFile { get; } = new DatasetType(UriFileValue); + /// URI folder. + public static DatasetType UriFolder { get; } = new DatasetType(UriFolderValue); + /// Determines if two values are the same. + public static bool operator ==(DatasetType left, DatasetType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DatasetType left, DatasetType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DatasetType(string value) => new DatasetType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DatasetType other && Equals(other); + /// + public bool Equals(DatasetType 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/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DatasetVersion.Serialization.cs similarity index 54% rename from sdk/ai/Azure.AI.Projects/src/Generated/RunStepDetails.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/DatasetVersion.Serialization.cs index 2cb1df56a281..6d2957778b00 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDetails.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DatasetVersion.Serialization.cs @@ -12,12 +12,12 @@ namespace Azure.AI.Projects { - [PersistableModelProxy(typeof(UnknownRunStepDetails))] - public partial class RunStepDetails : IUtf8JsonSerializable, IJsonModel + [PersistableModelProxy(typeof(UnknownDatasetVersion))] + public partial class DatasetVersion : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,14 +28,57 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(DatasetVersion)} does not support writing '{format}' format."); } + writer.WritePropertyName("dataUri"u8); + writer.WriteStringValue(DataUri); writer.WritePropertyName("type"u8); writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && Optional.IsDefined(IsReference)) + { + writer.WritePropertyName("isReference"u8); + writer.WriteBooleanValue(IsReference.Value); + } + if (Optional.IsDefined(ConnectionName)) + { + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -53,19 +96,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RunStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + DatasetVersion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(DatasetVersion)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDetails(document.RootElement, options); + return DeserializeDatasetVersion(document.RootElement, options); } - internal static RunStepDetails DeserializeRunStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + internal static DatasetVersion DeserializeDatasetVersion(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,50 +120,50 @@ internal static RunStepDetails DeserializeRunStepDetails(JsonElement element, Mo { switch (discriminator.GetString()) { - case "message_creation": return RunStepMessageCreationDetails.DeserializeRunStepMessageCreationDetails(element, options); - case "tool_calls": return RunStepToolCallDetails.DeserializeRunStepToolCallDetails(element, options); + case "uri_file": return FileDatasetVersion.DeserializeFileDatasetVersion(element, options); + case "uri_folder": return FolderDatasetVersion.DeserializeFolderDatasetVersion(element, options); } } - return UnknownRunStepDetails.DeserializeUnknownRunStepDetails(element, options); + return UnknownDatasetVersion.DeserializeUnknownDatasetVersion(element, options); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(DatasetVersion)} does not support writing '{options.Format}' format."); } } - RunStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + DatasetVersion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDetails(document.RootElement, options); + return DeserializeDatasetVersion(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(DatasetVersion)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static RunStepDetails FromResponse(Response response) + internal static DatasetVersion FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDetails(document.RootElement); + return DeserializeDatasetVersion(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DatasetVersion.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DatasetVersion.cs new file mode 100644 index 000000000000..545e5a8b21c0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DatasetVersion.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// DatasetVersion Definition + /// 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 DatasetVersion + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// is null. + protected DatasetVersion(string dataUri) + { + Argument.AssertNotNull(dataUri, nameof(dataUri)); + + DataUri = dataUri; + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal DatasetVersion(string dataUri, DatasetType type, bool? isReference, string connectionName, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) + { + DataUri = dataUri; + Type = type; + IsReference = isReference; + ConnectionName = connectionName; + Id = id; + Name = name; + Version = version; + Description = description; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DatasetVersion() + { + } + + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + public string DataUri { get; set; } + /// Dataset type. + internal DatasetType Type { get; set; } + /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + public bool? IsReference { get; } + /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. + public string ConnectionName { get; set; } + /// Asset ID, a unique identifier for the asset. + public string Id { get; } + /// The name of the resource. + public string Name { get; } + /// The version of the resource. + public string Version { get; } + /// The asset description text. + public string Description { get; set; } + /// Tag dictionary. Tags can be added, removed, and updated. + public IDictionary Tags { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Datasets.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Datasets.cs new file mode 100644 index 000000000000..1787d746fc8e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Datasets.cs @@ -0,0 +1,909 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects +{ + // Data plane generated sub-client. + /// The Datasets sub-client. + public partial class Datasets + { + private static readonly string[] AuthorizationScopes = new string[] { "https://ai.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Datasets for mocking. + protected Datasets() + { + } + + /// Initializes a new instance of Datasets. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// + /// The API version to use for this operation. + internal Datasets(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get the specific version of the DatasetVersion. + /// The name of the resource. + /// The specific version id of the DatasetVersion to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetDatasetAsync(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetDatasetAsync(name, version, context).ConfigureAwait(false); + return Response.FromValue(DatasetVersion.FromResponse(response), response); + } + + /// Get the specific version of the DatasetVersion. + /// The name of the resource. + /// The specific version id of the DatasetVersion to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetDataset(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetDataset(name, version, context); + return Response.FromValue(DatasetVersion.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get the specific version of the DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the DatasetVersion to retrieve. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetDatasetAsync(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.GetDataset"); + scope.Start(); + try + { + using HttpMessage message = CreateGetDatasetRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get the specific version of the DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the DatasetVersion to retrieve. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetDataset(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.GetDataset"); + scope.Start(); + try + { + using HttpMessage message = CreateGetDatasetRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the specific version of the DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The version of the DatasetVersion to delete. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteAsync(string name, string version, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the specific version of the DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The version of the DatasetVersion to delete. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Delete(string name, string version, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new or update an existing DatasetVersion with the given version id + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the DatasetVersion to create or replace. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateAsync(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(name, version, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new or update an existing DatasetVersion with the given version id + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the DatasetVersion to create or replace. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdate(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(name, version, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Start a new or get an existing pending upload of a dataset for a specific version. + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// Parameters for the action. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> PendingUploadAsync(string name, string version, PendingUploadRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await PendingUploadAsync(name, version, content, context).ConfigureAwait(false); + return Response.FromValue(PendingUploadResponse.FromResponse(response), response); + } + + /// Start a new or get an existing pending upload of a dataset for a specific version. + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// Parameters for the action. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response PendingUpload(string name, string version, PendingUploadRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = PendingUpload(name, version, content, context); + return Response.FromValue(PendingUploadResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Start a new or get an existing pending upload of a dataset for a specific version. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task PendingUploadAsync(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.PendingUpload"); + scope.Start(); + try + { + using HttpMessage message = CreatePendingUploadRequest(name, version, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Start a new or get an existing pending upload of a dataset for a specific version. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response PendingUpload(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.PendingUpload"); + scope.Start(); + try + { + using HttpMessage message = CreatePendingUploadRequest(name, version, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get the SAS credential to access the storage account associated with a Dataset version. + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetCredentialsAsync(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetCredentialsAsync(name, version, context).ConfigureAwait(false); + return Response.FromValue(AssetCredentialResponse.FromResponse(response), response); + } + + /// Get the SAS credential to access the storage account associated with a Dataset version. + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetCredentials(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetCredentials(name, version, context); + return Response.FromValue(AssetCredentialResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get the SAS credential to access the storage account associated with a Dataset version. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetCredentialsAsync(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.GetCredentials"); + scope.Start(); + try + { + using HttpMessage message = CreateGetCredentialsRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get the SAS credential to access the storage account associated with a Dataset version. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetCredentials(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.GetCredentials"); + scope.Start(); + try + { + using HttpMessage message = CreateGetCredentialsRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List all versions of the given DatasetVersion. + /// The name of the resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetVersionsAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DatasetVersion.DeserializeDatasetVersion(e), ClientDiagnostics, _pipeline, "Datasets.GetVersions", "value", "nextLink", context); + } + + /// List all versions of the given DatasetVersion. + /// The name of the resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetVersions(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DatasetVersion.DeserializeDatasetVersion(e), ClientDiagnostics, _pipeline, "Datasets.GetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all versions of the given DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetVersionsAsync(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Datasets.GetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all versions of the given DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetVersions(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Datasets.GetVersions", "value", "nextLink", context); + } + + /// List the latest version of each DatasetVersion. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetDatasetVersionsAsync(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDatasetVersionsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDatasetVersionsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DatasetVersion.DeserializeDatasetVersion(e), ClientDiagnostics, _pipeline, "Datasets.GetDatasetVersions", "value", "nextLink", context); + } + + /// List the latest version of each DatasetVersion. + /// The cancellation token to use. + /// + public virtual Pageable GetDatasetVersions(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDatasetVersionsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDatasetVersionsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DatasetVersion.DeserializeDatasetVersion(e), ClientDiagnostics, _pipeline, "Datasets.GetDatasetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the latest version of each DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetDatasetVersionsAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDatasetVersionsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDatasetVersionsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Datasets.GetDatasetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the latest version of each DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetDatasetVersions(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDatasetVersionsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDatasetVersionsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Datasets.GetDatasetVersions", "value", "nextLink", context); + } + + internal HttpMessage CreateGetVersionsRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetDatasetVersionsRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetDatasetRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string name, string version, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreatePendingUploadRequest(string name, string version, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendPath("/startPendingUpload", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetCredentialsRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendPath("/credentials", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetVersionsNextPageRequest(string nextLink, string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetDatasetVersionsNextPageRequest(string nextLink, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Deployment.Serialization.cs similarity index 62% rename from sdk/ai/Azure.AI.Projects/src/Generated/RequiredAction.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/Deployment.Serialization.cs index a1e5ca4eccef..046bf583b40d 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredAction.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Deployment.Serialization.cs @@ -12,12 +12,12 @@ namespace Azure.AI.Projects { - [PersistableModelProxy(typeof(UnknownRequiredAction))] - public partial class RequiredAction : IUtf8JsonSerializable, IJsonModel + [PersistableModelProxy(typeof(UnknownDeployment))] + public partial class Deployment : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,14 +28,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RequiredAction)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(Deployment)} does not support writing '{format}' format."); } writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -53,19 +58,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RequiredAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + Deployment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RequiredAction)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(Deployment)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRequiredAction(document.RootElement, options); + return DeserializeDeployment(document.RootElement, options); } - internal static RequiredAction DeserializeRequiredAction(JsonElement element, ModelReaderWriterOptions options = null) + internal static Deployment DeserializeDeployment(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,49 +82,49 @@ internal static RequiredAction DeserializeRequiredAction(JsonElement element, Mo { switch (discriminator.GetString()) { - case "submit_tool_outputs": return SubmitToolOutputsAction.DeserializeSubmitToolOutputsAction(element, options); + case "ModelDeployment": return ModelDeployment.DeserializeModelDeployment(element, options); } } - return UnknownRequiredAction.DeserializeUnknownRequiredAction(element, options); + return UnknownDeployment.DeserializeUnknownDeployment(element, options); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RequiredAction)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(Deployment)} does not support writing '{options.Format}' format."); } } - RequiredAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + Deployment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRequiredAction(document.RootElement, options); + return DeserializeDeployment(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RequiredAction)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(Deployment)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static RequiredAction FromResponse(Response response) + internal static Deployment FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRequiredAction(document.RootElement); + return DeserializeDeployment(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Deployment.cs similarity index 63% rename from sdk/ai/Azure.AI.Projects/src/Generated/RequiredAction.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/Deployment.cs index 8233fd69673e..3d36e6d4fadc 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredAction.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Deployment.cs @@ -11,11 +11,11 @@ namespace Azure.AI.Projects { /// - /// An abstract representation of a required action for an agent thread run to continue. - /// 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 . + /// Model Deployment Definition + /// 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 . /// - public abstract partial class RequiredAction + public abstract partial class Deployment { /// /// Keeps track of any properties unknown to the library. @@ -49,21 +49,25 @@ public abstract partial class RequiredAction /// private protected IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - protected RequiredAction() + /// Initializes a new instance of . + protected Deployment() { } - /// Initializes a new instance of . - /// The object type. + /// Initializes a new instance of . + /// The type of the deployment. + /// Name of the deployment. /// Keeps track of any properties unknown to the library. - internal RequiredAction(string type, IDictionary serializedAdditionalRawData) + internal Deployment(DeploymentType type, string name, IDictionary serializedAdditionalRawData) { Type = type; + Name = name; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// The object type. - internal string Type { get; set; } + /// The type of the deployment. + internal DeploymentType Type { get; set; } + /// Name of the deployment. + public string Name { get; } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DeploymentType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DeploymentType.cs new file mode 100644 index 000000000000..d34cf84db649 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DeploymentType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The DeploymentType. + public readonly partial struct DeploymentType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DeploymentType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ModelDeploymentValue = "ModelDeployment"; + + /// Model deployment. + public static DeploymentType ModelDeployment { get; } = new DeploymentType(ModelDeploymentValue); + /// Determines if two values are the same. + public static bool operator ==(DeploymentType left, DeploymentType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DeploymentType left, DeploymentType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DeploymentType(string value) => new DeploymentType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DeploymentType other && Equals(other); + /// + public bool Equals(DeploymentType 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/sdk/ai/Azure.AI.Projects/src/Generated/Deployments.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Deployments.cs new file mode 100644 index 000000000000..b6da194612da --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Deployments.cs @@ -0,0 +1,322 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects +{ + // Data plane generated sub-client. + /// The Deployments sub-client. + public partial class Deployments + { + private static readonly string[] AuthorizationScopes = new string[] { "https://ai.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Deployments for mocking. + protected Deployments() + { + } + + /// Initializes a new instance of Deployments. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// + /// The API version to use for this operation. + internal Deployments(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get a deployed model. + /// Name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetDeploymentAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetDeploymentAsync(name, context).ConfigureAwait(false); + return Response.FromValue(Deployment.FromResponse(response), response); + } + + /// Get a deployed model. + /// Name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetDeployment(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetDeployment(name, context); + return Response.FromValue(Deployment.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get a deployed model. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Name of the deployment. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetDeploymentAsync(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("Deployments.GetDeployment"); + scope.Start(); + try + { + using HttpMessage message = CreateGetDeploymentRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get a deployed model. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Name of the deployment. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetDeployment(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("Deployments.GetDeployment"); + scope.Start(); + try + { + using HttpMessage message = CreateGetDeploymentRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List all deployed models in the project. + /// Model publisher to filter models by. + /// Model name (the publisher specific name) to filter models by. + /// Type of deployment to filter list by. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetDeploymentsAsync(string modelPublisher = null, string modelName = null, DeploymentType? deploymentType = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(modelPublisher, modelName, deploymentType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, modelPublisher, modelName, deploymentType?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Deployment.DeserializeDeployment(e), ClientDiagnostics, _pipeline, "Deployments.GetDeployments", "value", "nextLink", context); + } + + /// List all deployed models in the project. + /// Model publisher to filter models by. + /// Model name (the publisher specific name) to filter models by. + /// Type of deployment to filter list by. + /// The cancellation token to use. + /// + public virtual Pageable GetDeployments(string modelPublisher = null, string modelName = null, DeploymentType? deploymentType = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(modelPublisher, modelName, deploymentType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, modelPublisher, modelName, deploymentType?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Deployment.DeserializeDeployment(e), ClientDiagnostics, _pipeline, "Deployments.GetDeployments", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all deployed models in the project + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Model publisher to filter models by. + /// Model name (the publisher specific name) to filter models by. + /// Type of deployment to filter list by. Allowed values: "ModelDeployment". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetDeploymentsAsync(string modelPublisher, string modelName, string deploymentType, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(modelPublisher, modelName, deploymentType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, modelPublisher, modelName, deploymentType, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Deployments.GetDeployments", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all deployed models in the project + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Model publisher to filter models by. + /// Model name (the publisher specific name) to filter models by. + /// Type of deployment to filter list by. Allowed values: "ModelDeployment". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetDeployments(string modelPublisher, string modelName, string deploymentType, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(modelPublisher, modelName, deploymentType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, modelPublisher, modelName, deploymentType, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Deployments.GetDeployments", "value", "nextLink", context); + } + + internal HttpMessage CreateGetDeploymentRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/deployments/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetDeploymentsRequest(string modelPublisher, string modelName, string deploymentType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/deployments", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (modelPublisher != null) + { + uri.AppendQuery("modelPublisher", modelPublisher, true); + } + if (modelName != null) + { + uri.AppendQuery("modelName", modelName, true); + } + if (deploymentType != null) + { + uri.AppendQuery("deploymentType", deploymentType, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetDeploymentsNextPageRequest(string nextLink, string modelPublisher, string modelName, string deploymentType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Docs/ConnectionsClient.xml b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/ConnectionsClient.xml new file mode 100644 index 000000000000..ad420d965bd5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/ConnectionsClient.xml @@ -0,0 +1,73 @@ + + + + + +This sample shows how to call GetConnectionsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +ConnectionsClient client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-15-preview"); + +await foreach (Connection item in client.GetConnectionsAsync()) +{ +} +]]> + + + +This sample shows how to call GetConnections. +"); +TokenCredential credential = new DefaultAzureCredential(); +ConnectionsClient client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-15-preview"); + +foreach (Connection item in client.GetConnections()) +{ +} +]]> + + + +This sample shows how to call GetConnectionsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +ConnectionsClient client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetConnectionsAsync("AzureOpenAI", true, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("isDefault").ToString()); + Console.WriteLine(result.GetProperty("credentials").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetConnections and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +ConnectionsClient client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetConnections("AzureOpenAI", true, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("isDefault").ToString()); + Console.WriteLine(result.GetProperty("credentials").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Datasets.xml b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Datasets.xml new file mode 100644 index 000000000000..48ca95a6e1d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Datasets.xml @@ -0,0 +1,749 @@ + + + + + +This sample shows how to call GetDatasetAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetDatasetAsync("", ""); +]]> +This sample shows how to call GetDatasetAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetDatasetAsync("", ""); +]]> + + + +This sample shows how to call GetDataset. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetDataset("", ""); +]]> +This sample shows how to call GetDataset with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetDataset("", ""); +]]> + + + +This sample shows how to call GetDatasetAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetDatasetAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("dataUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call GetDatasetAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetDatasetAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("dataUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("connectionName").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetDataset and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetDataset("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("dataUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call GetDataset with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetDataset("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("dataUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("connectionName").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call DeleteAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.DeleteAsync("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.DeleteAsync("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Delete. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.Delete("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call Delete with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.Delete("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call CreateOrUpdateAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + dataUri = "", +}); +Response response = await client.CreateOrUpdateAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("dataUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateOrUpdateAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + dataUri = "", + connectionName = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = await client.CreateOrUpdateAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("dataUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("connectionName").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdate and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + dataUri = "", +}); +Response response = client.CreateOrUpdate("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("dataUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateOrUpdate with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + dataUri = "", + connectionName = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = client.CreateOrUpdate("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("dataUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("connectionName").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call PendingUploadAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +PendingUploadRequest body = new PendingUploadRequest +{ + PendingUploadId = "mxjahcghabuplfwtlopiqgxtcyw", + ConnectionName = "bknvpmlisrqxaphkf", +}; +Response response = await client.PendingUploadAsync("sgrzyrpltz", "ozdqisviavgqgfbtnzk", body); +]]> +This sample shows how to call PendingUploadAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +PendingUploadRequest body = new PendingUploadRequest(); +Response response = await client.PendingUploadAsync("duxoiaywfik", "yzzzt", body); +]]> + + + +This sample shows how to call PendingUpload. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +PendingUploadRequest body = new PendingUploadRequest +{ + PendingUploadId = "mxjahcghabuplfwtlopiqgxtcyw", + ConnectionName = "bknvpmlisrqxaphkf", +}; +Response response = client.PendingUpload("sgrzyrpltz", "ozdqisviavgqgfbtnzk", body); +]]> +This sample shows how to call PendingUpload. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +PendingUploadRequest body = new PendingUploadRequest(); +Response response = client.PendingUpload("duxoiaywfik", "yzzzt", body); +]]> + + + +This sample shows how to call PendingUploadAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadId = "mxjahcghabuplfwtlopiqgxtcyw", + connectionName = "bknvpmlisrqxaphkf", + pendingUploadType = "BlobReference", +}); +Response response = await client.PendingUploadAsync("sgrzyrpltz", "ozdqisviavgqgfbtnzk", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> +This sample shows how to call PendingUploadAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadType = "BlobReference", +}); +Response response = await client.PendingUploadAsync("duxoiaywfik", "yzzzt", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> + + + +This sample shows how to call PendingUpload and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadId = "mxjahcghabuplfwtlopiqgxtcyw", + connectionName = "bknvpmlisrqxaphkf", + pendingUploadType = "BlobReference", +}); +Response response = client.PendingUpload("sgrzyrpltz", "ozdqisviavgqgfbtnzk", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> +This sample shows how to call PendingUpload and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadType = "BlobReference", +}); +Response response = client.PendingUpload("duxoiaywfik", "yzzzt", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> + + + +This sample shows how to call GetCredentialsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetCredentialsAsync("vzqmzhfdzfqegdk", "cuiflnznlzybcrc"); +]]> +This sample shows how to call GetCredentialsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetCredentialsAsync("sbblxkyqnfvdiqacezyygvts", "ikak"); +]]> + + + +This sample shows how to call GetCredentials. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetCredentials("vzqmzhfdzfqegdk", "cuiflnznlzybcrc"); +]]> +This sample shows how to call GetCredentials. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetCredentials("sbblxkyqnfvdiqacezyygvts", "ikak"); +]]> + + + +This sample shows how to call GetCredentialsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetCredentialsAsync("vzqmzhfdzfqegdk", "cuiflnznlzybcrc", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); +]]> +This sample shows how to call GetCredentialsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetCredentialsAsync("sbblxkyqnfvdiqacezyygvts", "ikak", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetCredentials and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetCredentials("vzqmzhfdzfqegdk", "cuiflnznlzybcrc", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); +]]> +This sample shows how to call GetCredentials and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetCredentials("sbblxkyqnfvdiqacezyygvts", "ikak", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); +Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetVersionsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +await foreach (DatasetVersion item in client.GetVersionsAsync("")) +{ +} +]]> +This sample shows how to call GetVersionsAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +await foreach (DatasetVersion item in client.GetVersionsAsync("")) +{ +} +]]> + + + +This sample shows how to call GetVersions. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +foreach (DatasetVersion item in client.GetVersions("")) +{ +} +]]> +This sample shows how to call GetVersions with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +foreach (DatasetVersion item in client.GetVersions("")) +{ +} +]]> + + + +This sample shows how to call GetVersionsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetVersionsAsync("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetVersionsAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetVersionsAsync("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetVersions and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetVersions("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetVersions with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetVersions("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetDatasetVersionsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +await foreach (DatasetVersion item in client.GetDatasetVersionsAsync()) +{ +} +]]> +This sample shows how to call GetDatasetVersionsAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +await foreach (DatasetVersion item in client.GetDatasetVersionsAsync()) +{ +} +]]> + + + +This sample shows how to call GetDatasetVersions. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +foreach (DatasetVersion item in client.GetDatasetVersions()) +{ +} +]]> +This sample shows how to call GetDatasetVersions with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +foreach (DatasetVersion item in client.GetDatasetVersions()) +{ +} +]]> + + + +This sample shows how to call GetDatasetVersionsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetDatasetVersionsAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetDatasetVersionsAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetDatasetVersionsAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetDatasetVersions and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetDatasetVersions(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetDatasetVersions with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetDatasetVersions(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Deployments.xml b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Deployments.xml new file mode 100644 index 000000000000..016331ea6914 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Deployments.xml @@ -0,0 +1,115 @@ + + + + + +This sample shows how to call GetDeploymentAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetDeploymentAsync("qqvacpzjfk"); +]]> + + + +This sample shows how to call GetDeployment. +"); +TokenCredential credential = new DefaultAzureCredential(); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetDeployment("qqvacpzjfk"); +]]> + + + +This sample shows how to call GetDeploymentAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetDeploymentAsync("qqvacpzjfk", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +]]> + + + +This sample shows how to call GetDeployment and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetDeployment("qqvacpzjfk", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +]]> + + + +This sample shows how to call GetDeploymentsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + +await foreach (Deployment item in client.GetDeploymentsAsync()) +{ +} +]]> + + + +This sample shows how to call GetDeployments. +"); +TokenCredential credential = new DefaultAzureCredential(); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + +foreach (Deployment item in client.GetDeployments()) +{ +} +]]> + + + +This sample shows how to call GetDeploymentsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetDeploymentsAsync("kznreojrvlwdq", "gplerszsuyisseeksnyvkaqperxox", null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); +} +]]> + + + +This sample shows how to call GetDeployments and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetDeployments("kznreojrvlwdq", "gplerszsuyisseeksnyvkaqperxox", null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Docs/EvaluationsClient.xml b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/EvaluationsClient.xml new file mode 100644 index 000000000000..5f3f10591406 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/EvaluationsClient.xml @@ -0,0 +1,521 @@ + + + + + +This sample shows how to call GetEvaluationAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetEvaluationAsync("so"); +]]> + + + +This sample shows how to call GetEvaluation. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetEvaluation("so"); +]]> + + + +This sample shows how to call GetEvaluationAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetEvaluationAsync("so", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> + + + +This sample shows how to call GetEvaluation and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetEvaluation("so", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +Evaluation evaluation = new Evaluation(null, new Dictionary +{ + ["key2735"] = new EvaluatorConfiguration("gujwtvhptykq") + { + InitParams = { }, + DataMapping = + { + ["key7400"] = "ijkjfvoswni" + }, + } +}) +{ + DisplayName = "ymjxkodggqrhjnmusta", + Description = "cuviaxytqckkybxwc", + Tags = + { + ["key30"] = "nqrdpedyhkjzgrbtqhxbmkdmlpdf" + }, + Properties = + { + ["key9192"] = "e" + }, +}; +Response response = await client.CreateAsync(evaluation); +]]> +This sample shows how to call CreateAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +Evaluation evaluation = new Evaluation(null, new Dictionary()); +Response response = await client.CreateAsync(evaluation); +]]> + + + +This sample shows how to call Create. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +Evaluation evaluation = new Evaluation(null, new Dictionary +{ + ["key2735"] = new EvaluatorConfiguration("gujwtvhptykq") + { + InitParams = { }, + DataMapping = + { + ["key7400"] = "ijkjfvoswni" + }, + } +}) +{ + DisplayName = "ymjxkodggqrhjnmusta", + Description = "cuviaxytqckkybxwc", + Tags = + { + ["key30"] = "nqrdpedyhkjzgrbtqhxbmkdmlpdf" + }, + Properties = + { + ["key9192"] = "e" + }, +}; +Response response = client.Create(evaluation); +]]> +This sample shows how to call Create. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +Evaluation evaluation = new Evaluation(null, new Dictionary()); +Response response = client.Create(evaluation); +]]> + + + +This sample shows how to call CreateAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "ymjxkodggqrhjnmusta", + description = "cuviaxytqckkybxwc", + tags = new + { + key30 = "nqrdpedyhkjzgrbtqhxbmkdmlpdf", + }, + properties = new + { + key9192 = "e", + }, + evaluators = new + { + key2735 = new + { + id = "gujwtvhptykq", + initParams = new object(), + dataMapping = new + { + key7400 = "ijkjfvoswni", + }, + }, + }, +}); +Response response = await client.CreateAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> +This sample shows how to call CreateAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + evaluators = new object(), +}); +Response response = await client.CreateAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> + + + +This sample shows how to call Create and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "ymjxkodggqrhjnmusta", + description = "cuviaxytqckkybxwc", + tags = new + { + key30 = "nqrdpedyhkjzgrbtqhxbmkdmlpdf", + }, + properties = new + { + key9192 = "e", + }, + evaluators = new + { + key2735 = new + { + id = "gujwtvhptykq", + initParams = new object(), + dataMapping = new + { + key7400 = "ijkjfvoswni", + }, + }, + }, +}); +Response response = client.Create(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> +This sample shows how to call Create and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + evaluators = new object(), +}); +Response response = client.Create(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateAgentEvaluationAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +AgentEvaluationRequest evaluation = new AgentEvaluationRequest("ecfcffqsrdhpecocrufffiqz", new Dictionary +{ + ["key2653"] = new EvaluatorConfiguration("gujwtvhptykq") + { + InitParams = { }, + DataMapping = + { + ["key7400"] = "ijkjfvoswni" + }, + } +}, "dvcnrcwar") +{ + ThreadId = "cxjjsyhkeezgnaqqyerrdrbbth", + SamplingConfiguration = new AgentEvaluationSamplingConfiguration("tj", 7F, 8F), + RedactionConfiguration = new AgentEvaluationRedactionConfiguration + { + RedactScoreProperties = true, + }, +}; +Response response = await client.CreateAgentEvaluationAsync(evaluation); +]]> +This sample shows how to call CreateAgentEvaluationAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +AgentEvaluationRequest evaluation = new AgentEvaluationRequest("ecfcffqsrdhpecocrufffiqz", new Dictionary(), "dvcnrcwar"); +Response response = await client.CreateAgentEvaluationAsync(evaluation); +]]> + + + +This sample shows how to call CreateAgentEvaluation. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +AgentEvaluationRequest evaluation = new AgentEvaluationRequest("ecfcffqsrdhpecocrufffiqz", new Dictionary +{ + ["key2653"] = new EvaluatorConfiguration("gujwtvhptykq") + { + InitParams = { }, + DataMapping = + { + ["key7400"] = "ijkjfvoswni" + }, + } +}, "dvcnrcwar") +{ + ThreadId = "cxjjsyhkeezgnaqqyerrdrbbth", + SamplingConfiguration = new AgentEvaluationSamplingConfiguration("tj", 7F, 8F), + RedactionConfiguration = new AgentEvaluationRedactionConfiguration + { + RedactScoreProperties = true, + }, +}; +Response response = client.CreateAgentEvaluation(evaluation); +]]> +This sample shows how to call CreateAgentEvaluation. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +AgentEvaluationRequest evaluation = new AgentEvaluationRequest("ecfcffqsrdhpecocrufffiqz", new Dictionary(), "dvcnrcwar"); +Response response = client.CreateAgentEvaluation(evaluation); +]]> + + + +This sample shows how to call CreateAgentEvaluationAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + runId = "ecfcffqsrdhpecocrufffiqz", + threadId = "cxjjsyhkeezgnaqqyerrdrbbth", + evaluators = new + { + key2653 = new + { + id = "gujwtvhptykq", + initParams = new object(), + dataMapping = new + { + key7400 = "ijkjfvoswni", + }, + }, + }, + samplingConfiguration = new + { + name = "tj", + samplingPercent = 7F, + maxRequestRate = 8F, + }, + redactionConfiguration = new + { + redactScoreProperties = true, + }, + appInsightsConnectionString = "dvcnrcwar", +}); +Response response = await client.CreateAgentEvaluationAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +]]> +This sample shows how to call CreateAgentEvaluationAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + runId = "ecfcffqsrdhpecocrufffiqz", + evaluators = new object(), + appInsightsConnectionString = "dvcnrcwar", +}); +Response response = await client.CreateAgentEvaluationAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +]]> + + + +This sample shows how to call CreateAgentEvaluation and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + runId = "ecfcffqsrdhpecocrufffiqz", + threadId = "cxjjsyhkeezgnaqqyerrdrbbth", + evaluators = new + { + key2653 = new + { + id = "gujwtvhptykq", + initParams = new object(), + dataMapping = new + { + key7400 = "ijkjfvoswni", + }, + }, + }, + samplingConfiguration = new + { + name = "tj", + samplingPercent = 7F, + maxRequestRate = 8F, + }, + redactionConfiguration = new + { + redactScoreProperties = true, + }, + appInsightsConnectionString = "dvcnrcwar", +}); +Response response = client.CreateAgentEvaluation(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +]]> +This sample shows how to call CreateAgentEvaluation and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + runId = "ecfcffqsrdhpecocrufffiqz", + evaluators = new object(), + appInsightsConnectionString = "dvcnrcwar", +}); +Response response = client.CreateAgentEvaluation(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +]]> + + + +This sample shows how to call GetEvaluationsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +await foreach (Evaluation item in client.GetEvaluationsAsync()) +{ +} +]]> + + + +This sample shows how to call GetEvaluations. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +foreach (Evaluation item in client.GetEvaluations()) +{ +} +]]> + + + +This sample shows how to call GetEvaluationsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetEvaluationsAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +} +]]> + + + +This sample shows how to call GetEvaluations and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetEvaluations(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Indexes.xml b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Indexes.xml new file mode 100644 index 000000000000..7a103b1f70cd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/Indexes.xml @@ -0,0 +1,515 @@ + + + + + +This sample shows how to call GetIndexAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetIndexAsync("", ""); +]]> +This sample shows how to call GetIndexAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetIndexAsync("", ""); +]]> + + + +This sample shows how to call GetIndex. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetIndex("", ""); +]]> +This sample shows how to call GetIndex with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetIndex("", ""); +]]> + + + +This sample shows how to call GetIndexAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetIndexAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call GetIndexAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetIndexAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetIndex and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetIndex("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call GetIndex with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetIndex("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call DeleteAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.DeleteAsync("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.DeleteAsync("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Delete. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = client.Delete("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call Delete with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +Response response = client.Delete("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call CreateOrUpdateAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", +}); +Response response = await client.CreateOrUpdateAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateOrUpdateAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", + fieldMapping = new + { + contentFields = new object[] + { + "" + }, + filepathField = "", + titleField = "", + urlField = "", + vectorFields = new object[] + { + "" + }, + metadataFields = new object[] + { + "" + }, + }, + description = "", + tags = new + { + key = "", + }, +}); +Response response = await client.CreateOrUpdateAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdate and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", +}); +Response response = client.CreateOrUpdate("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateOrUpdate with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", + fieldMapping = new + { + contentFields = new object[] + { + "" + }, + filepathField = "", + titleField = "", + urlField = "", + vectorFields = new object[] + { + "" + }, + metadataFields = new object[] + { + "" + }, + }, + description = "", + tags = new + { + key = "", + }, +}); +Response response = client.CreateOrUpdate("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetVersionsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +await foreach (Index item in client.GetVersionsAsync("")) +{ +} +]]> +This sample shows how to call GetVersionsAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +await foreach (Index item in client.GetVersionsAsync("")) +{ +} +]]> + + + +This sample shows how to call GetVersions. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +foreach (Index item in client.GetVersions("")) +{ +} +]]> +This sample shows how to call GetVersions with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +foreach (Index item in client.GetVersions("")) +{ +} +]]> + + + +This sample shows how to call GetVersionsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetVersionsAsync("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetVersionsAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetVersionsAsync("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetVersions and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetVersions("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetVersions with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetVersions("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetIndicesAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +await foreach (Index item in client.GetIndicesAsync()) +{ +} +]]> +This sample shows how to call GetIndicesAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +await foreach (Index item in client.GetIndicesAsync()) +{ +} +]]> + + + +This sample shows how to call GetIndices. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +foreach (Index item in client.GetIndices()) +{ +} +]]> +This sample shows how to call GetIndices with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +foreach (Index item in client.GetIndices()) +{ +} +]]> + + + +This sample shows how to call GetIndicesAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetIndicesAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetIndicesAsync with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetIndicesAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetIndices and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetIndices(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetIndices with all parameters and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetIndices(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Docs/RedTeams.xml b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/RedTeams.xml new file mode 100644 index 000000000000..76a475b7d29a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Docs/RedTeams.xml @@ -0,0 +1,323 @@ + + + + + +This sample shows how to call GetRedTeamAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetRedTeamAsync("apwpcf"); +]]> + + + +This sample shows how to call GetRedTeam. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetRedTeam("apwpcf"); +]]> + + + +This sample shows how to call GetRedTeamAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +Response response = await client.GetRedTeamAsync("apwpcf", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetRedTeam and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +Response response = client.GetRedTeam("apwpcf", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call CreateAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +RedTeam redTeam = new RedTeam(null) +{ + NumTurns = 10, + AttackStrategies = { AttackStrategy.Easy }, + SimulationOnly = true, + RiskCategories = { RiskCategory.HateUnfairness }, + ApplicationScenario = "qaxxxhjp", + Tags = + { + ["key1287"] = "gbklekkgmxkfbhehgh" + }, + Properties = + { + ["key9280"] = "fwzjtipl" + }, +}; +Response response = await client.CreateAsync(redTeam); +]]> +This sample shows how to call CreateAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +RedTeam redTeam = new RedTeam(null) +{ + NumTurns = 10, + AttackStrategies = { AttackStrategy.Easy }, + SimulationOnly = true, + RiskCategories = { RiskCategory.HateUnfairness }, +}; +Response response = await client.CreateAsync(redTeam); +]]> + + + +This sample shows how to call Create. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +RedTeam redTeam = new RedTeam(null) +{ + NumTurns = 10, + AttackStrategies = { AttackStrategy.Easy }, + SimulationOnly = true, + RiskCategories = { RiskCategory.HateUnfairness }, + ApplicationScenario = "qaxxxhjp", + Tags = + { + ["key1287"] = "gbklekkgmxkfbhehgh" + }, + Properties = + { + ["key9280"] = "fwzjtipl" + }, +}; +Response response = client.Create(redTeam); +]]> +This sample shows how to call Create. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +RedTeam redTeam = new RedTeam(null) +{ + NumTurns = 10, + AttackStrategies = { AttackStrategy.Easy }, + SimulationOnly = true, + RiskCategories = { RiskCategory.HateUnfairness }, +}; +Response response = client.Create(redTeam); +]]> + + + +This sample shows how to call CreateAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + numTurns = 10, + attackStrategies = new object[] + { + "easy" + }, + simulationOnly = true, + riskCategories = new object[] + { + "HateUnfairness" + }, + applicationScenario = "qaxxxhjp", + tags = new + { + key1287 = "gbklekkgmxkfbhehgh", + }, + properties = new + { + key9280 = "fwzjtipl", + }, +}); +Response response = await client.CreateAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); +]]> +This sample shows how to call CreateAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + numTurns = 10, + attackStrategies = new object[] + { + "easy" + }, + simulationOnly = true, + riskCategories = new object[] + { + "HateUnfairness" + }, +}); +Response response = await client.CreateAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call Create and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + numTurns = 10, + attackStrategies = new object[] + { + "easy" + }, + simulationOnly = true, + riskCategories = new object[] + { + "HateUnfairness" + }, + applicationScenario = "qaxxxhjp", + tags = new + { + key1287 = "gbklekkgmxkfbhehgh", + }, + properties = new + { + key9280 = "fwzjtipl", + }, +}); +Response response = client.Create(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); +]]> +This sample shows how to call Create and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +using RequestContent content = RequestContent.Create(new +{ + numTurns = 10, + attackStrategies = new object[] + { + "easy" + }, + simulationOnly = true, + riskCategories = new object[] + { + "HateUnfairness" + }, +}); +Response response = client.Create(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetRedTeamsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +await foreach (RedTeam item in client.GetRedTeamsAsync()) +{ +} +]]> + + + +This sample shows how to call GetRedTeams. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +foreach (RedTeam item in client.GetRedTeams()) +{ +} +]]> + + + +This sample shows how to call GetRedTeamsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +await foreach (BinaryData item in client.GetRedTeamsAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); +} +]]> + + + +This sample shows how to call GetRedTeams and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + +foreach (BinaryData item in client.GetRedTeams(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DoneEvent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DoneEvent.cs deleted file mode 100644 index 9f658de4258c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/DoneEvent.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Terminal event indicating the successful end of a stream. - public readonly partial struct DoneEvent : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DoneEvent(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string DoneValue = "done"; - - /// Event sent when the stream is done. - public static DoneEvent Done { get; } = new DoneEvent(DoneValue); - /// Determines if two values are the same. - public static bool operator ==(DoneEvent left, DoneEvent right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(DoneEvent left, DoneEvent right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator DoneEvent(string value) => new DoneEvent(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is DoneEvent other && Equals(other); - /// - public bool Equals(DoneEvent 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/sdk/ai/Azure.AI.Projects/src/Generated/GetAppInsightsResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EmbeddingConfiguration.Serialization.cs similarity index 64% rename from sdk/ai/Azure.AI.Projects/src/Generated/GetAppInsightsResponse.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/EmbeddingConfiguration.Serialization.cs index 276e6326583b..a61517c1eee2 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/GetAppInsightsResponse.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EmbeddingConfiguration.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class GetAppInsightsResponse : IUtf8JsonSerializable, IJsonModel + public partial class EmbeddingConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,18 +28,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(GetAppInsightsResponse)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(EmbeddingConfiguration)} does not support writing '{format}' format."); } - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("properties"u8); - writer.WriteObjectValue(Properties, options); + writer.WritePropertyName("modelDeploymentName"u8); + writer.WriteStringValue(ModelDeploymentName); + writer.WritePropertyName("embeddingField"u8); + writer.WriteStringValue(EmbeddingField); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -57,19 +55,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GetAppInsightsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + EmbeddingConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(GetAppInsightsResponse)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(EmbeddingConfiguration)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetAppInsightsResponse(document.RootElement, options); + return DeserializeEmbeddingConfiguration(document.RootElement, options); } - internal static GetAppInsightsResponse DeserializeGetAppInsightsResponse(JsonElement element, ModelReaderWriterOptions options = null) + internal static EmbeddingConfiguration DeserializeEmbeddingConfiguration(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,26 +75,20 @@ internal static GetAppInsightsResponse DeserializeGetAppInsightsResponse(JsonEle { return null; } - string id = default; - string name = default; - AppInsightsProperties properties = default; + string modelDeploymentName = default; + string embeddingField = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (property.NameEquals("modelDeploymentName"u8)) { - id = property.Value.GetString(); + modelDeploymentName = property.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (property.NameEquals("embeddingField"u8)) { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("properties"u8)) - { - properties = AppInsightsProperties.DeserializeAppInsightsProperties(property.Value, options); + embeddingField = property.Value.GetString(); continue; } if (options.Format != "W") @@ -105,46 +97,46 @@ internal static GetAppInsightsResponse DeserializeGetAppInsightsResponse(JsonEle } } serializedAdditionalRawData = rawDataDictionary; - return new GetAppInsightsResponse(id, name, properties, serializedAdditionalRawData); + return new EmbeddingConfiguration(modelDeploymentName, embeddingField, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(GetAppInsightsResponse)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(EmbeddingConfiguration)} does not support writing '{options.Format}' format."); } } - GetAppInsightsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + EmbeddingConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetAppInsightsResponse(document.RootElement, options); + return DeserializeEmbeddingConfiguration(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(GetAppInsightsResponse)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(EmbeddingConfiguration)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static GetAppInsightsResponse FromResponse(Response response) + internal static EmbeddingConfiguration FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetAppInsightsResponse(document.RootElement); + return DeserializeEmbeddingConfiguration(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EmbeddingConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EmbeddingConfiguration.cs new file mode 100644 index 000000000000..ecef0ee3ad8b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EmbeddingConfiguration.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 +{ + /// Embedding configuration class. + public partial class EmbeddingConfiguration + { + /// + /// 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 . + /// Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. + /// Embedding field. + /// or is null. + public EmbeddingConfiguration(string modelDeploymentName, string embeddingField) + { + Argument.AssertNotNull(modelDeploymentName, nameof(modelDeploymentName)); + Argument.AssertNotNull(embeddingField, nameof(embeddingField)); + + ModelDeploymentName = modelDeploymentName; + EmbeddingField = embeddingField; + } + + /// Initializes a new instance of . + /// Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. + /// Embedding field. + /// Keeps track of any properties unknown to the library. + internal EmbeddingConfiguration(string modelDeploymentName, string embeddingField, IDictionary serializedAdditionalRawData) + { + ModelDeploymentName = modelDeploymentName; + EmbeddingField = embeddingField; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EmbeddingConfiguration() + { + } + + /// Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. + public string ModelDeploymentName { get; set; } + /// Embedding field. + public string EmbeddingField { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EntraIDCredentials.Serialization.cs similarity index 67% rename from sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/EntraIDCredentials.Serialization.cs index 10c12cd27d42..6ba161089e55 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EntraIDCredentials.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class UnknownRunStepDeltaDetail : IUtf8JsonSerializable, IJsonModel + public partial class EntraIDCredentials : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,28 +28,28 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(EntraIDCredentials)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); } - RunStepDeltaDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + EntraIDCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(EntraIDCredentials)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaDetail(document.RootElement, options); + return DeserializeEntraIDCredentials(document.RootElement, options); } - internal static UnknownRunStepDeltaDetail DeserializeUnknownRunStepDeltaDetail(JsonElement element, ModelReaderWriterOptions options = null) + internal static EntraIDCredentials DeserializeEntraIDCredentials(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -57,14 +57,14 @@ internal static UnknownRunStepDeltaDetail DeserializeUnknownRunStepDeltaDetail(J { return null; } - string type = "Unknown"; + CredentialType type = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) { - type = property.Value.GetString(); + type = new CredentialType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -73,53 +73,53 @@ internal static UnknownRunStepDeltaDetail DeserializeUnknownRunStepDeltaDetail(J } } serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepDeltaDetail(type, serializedAdditionalRawData); + return new EntraIDCredentials(type, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(EntraIDCredentials)} does not support writing '{options.Format}' format."); } } - RunStepDeltaDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + EntraIDCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaDetail(document.RootElement, options); + return DeserializeEntraIDCredentials(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(EntraIDCredentials)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new UnknownRunStepDeltaDetail FromResponse(Response response) + internal static new EntraIDCredentials FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownRunStepDeltaDetail(document.RootElement); + return DeserializeEntraIDCredentials(document.RootElement); } /// Convert into a . internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EntraIDCredentials.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EntraIDCredentials.cs new file mode 100644 index 000000000000..2dcdb9431743 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EntraIDCredentials.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Entra ID credential definition. + public partial class EntraIDCredentials : BaseCredentials + { + /// Initializes a new instance of . + internal EntraIDCredentials() + { + Type = CredentialType.EntraId; + } + + /// Initializes a new instance of . + /// The type of credential used by the connection. + /// Keeps track of any properties unknown to the library. + internal EntraIDCredentials(CredentialType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ErrorEvent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ErrorEvent.cs deleted file mode 100644 index ea570033f684..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ErrorEvent.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Terminal event indicating a server side error while streaming. - public readonly partial struct ErrorEvent : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public ErrorEvent(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ErrorValue = "error"; - - /// Event sent when an error occurs, such as an internal server error or a timeout. - public static ErrorEvent Error { get; } = new ErrorEvent(ErrorValue); - /// Determines if two values are the same. - public static bool operator ==(ErrorEvent left, ErrorEvent right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(ErrorEvent left, ErrorEvent right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator ErrorEvent(string value) => new ErrorEvent(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ErrorEvent other && Equals(other); - /// - public bool Equals(ErrorEvent 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/sdk/ai/Azure.AI.Projects/src/Generated/Evaluation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Evaluation.Serialization.cs index 089900fbbd61..f5a8926a18bd 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Evaluation.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Evaluation.Serialization.cs @@ -37,15 +37,10 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (options.Format != "W") { writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WriteStringValue(Name); } writer.WritePropertyName("data"u8); writer.WriteObjectValue(Data, options); - if (Optional.IsDefined(Target)) - { - writer.WritePropertyName("target"u8); - writer.WriteObjectValue(Target, options); - } if (Optional.IsDefined(DisplayName)) { writer.WritePropertyName("displayName"u8); @@ -56,11 +51,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("description"u8); writer.WriteStringValue(Description); } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - writer.WriteObjectValue(SystemData, options); - } if (options.Format != "W" && Optional.IsDefined(Status)) { writer.WritePropertyName("status"u8); @@ -135,10 +125,8 @@ internal static Evaluation DeserializeEvaluation(JsonElement element, ModelReade } string id = default; InputData data = default; - EvaluationTarget target = default; string displayName = default; string description = default; - SystemData systemData = default; string status = default; IDictionary tags = default; IDictionary properties = default; @@ -157,15 +145,6 @@ internal static Evaluation DeserializeEvaluation(JsonElement element, ModelReade data = InputData.DeserializeInputData(property.Value, options); continue; } - if (property.NameEquals("target"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - target = EvaluationTarget.DeserializeEvaluationTarget(property.Value, options); - continue; - } if (property.NameEquals("displayName"u8)) { displayName = property.Value.GetString(); @@ -176,15 +155,6 @@ internal static Evaluation DeserializeEvaluation(JsonElement element, ModelReade description = property.Value.GetString(); continue; } - if (property.NameEquals("systemData"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - systemData = SystemData.DeserializeSystemData(property.Value, options); - continue; - } if (property.NameEquals("status"u8)) { status = property.Value.GetString(); @@ -237,10 +207,8 @@ internal static Evaluation DeserializeEvaluation(JsonElement element, ModelReade return new Evaluation( id, data, - target, displayName, description, - systemData, status, tags ?? new ChangeTrackingDictionary(), properties ?? new ChangeTrackingDictionary(), diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Evaluation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Evaluation.cs index f40d8ceaad92..66db63de881c 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Evaluation.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Evaluation.cs @@ -49,7 +49,7 @@ public partial class Evaluation /// /// Data for evaluation. /// 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 . /// /// Evaluators to be used for the evaluation. /// or is null. @@ -65,29 +65,25 @@ public Evaluation(InputData data, IDictionary ev } /// Initializes a new instance of . - /// Identifier of the evaluation. + /// Identifier of the evaluation. /// /// Data for evaluation. /// 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 . /// - /// Evaluation target specifying the model config and parameters. /// Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. - /// Metadata containing createdBy and modifiedBy information. /// Status of the evaluation. It is set by service and is read-only. /// Evaluation's tags. Unlike properties, tags are fully mutable. /// Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. /// Evaluators to be used for the evaluation. /// Keeps track of any properties unknown to the library. - internal Evaluation(string id, InputData data, EvaluationTarget target, string displayName, string description, SystemData systemData, string status, IDictionary tags, IDictionary properties, IDictionary evaluators, IDictionary serializedAdditionalRawData) + internal Evaluation(string name, InputData data, string displayName, string description, string status, IDictionary tags, IDictionary properties, IDictionary evaluators, IDictionary serializedAdditionalRawData) { - Id = id; + Name = name; Data = data; - Target = target; DisplayName = displayName; Description = description; - SystemData = systemData; Status = status; Tags = tags; Properties = properties; @@ -101,21 +97,17 @@ internal Evaluation() } /// Identifier of the evaluation. - public string Id { get; } + public string Name { get; } /// /// Data for evaluation. /// 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 . /// public InputData Data { get; set; } - /// Evaluation target specifying the model config and parameters. - public EvaluationTarget Target { get; set; } /// Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. public string DisplayName { get; set; } /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. public string Description { get; set; } - /// Metadata containing createdBy and modifiedBy information. - public SystemData SystemData { get; } /// Status of the evaluation. It is set by service and is read-only. public string Status { get; } /// Evaluation's tags. Unlike properties, tags are fully mutable. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationSchedule.cs deleted file mode 100644 index ad1104435458..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationSchedule.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Evaluation Schedule Definition. - public partial class EvaluationSchedule - { - /// - /// 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 . - /// Data for evaluation. - /// Evaluators to be used for the evaluation. - /// - /// Trigger for the evaluation. - /// 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 . - /// - /// , or is null. - public EvaluationSchedule(ApplicationInsightsConfiguration data, IDictionary evaluators, Trigger trigger) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(evaluators, nameof(evaluators)); - Argument.AssertNotNull(trigger, nameof(trigger)); - - Data = data; - Tags = new ChangeTrackingDictionary(); - Properties = new ChangeTrackingDictionary(); - Evaluators = evaluators; - Trigger = trigger; - } - - /// Initializes a new instance of . - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - /// Data for evaluation. - /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. - /// Metadata containing createdBy and modifiedBy information. - /// Provisioning State of the evaluation. It is set by service and is read-only. - /// Evaluation's tags. Unlike properties, tags are fully mutable. - /// Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. - /// Enabled status of the evaluation. It is set by service and is read-only. - /// Evaluators to be used for the evaluation. - /// - /// Trigger for the evaluation. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal EvaluationSchedule(string name, ApplicationInsightsConfiguration data, string description, SystemData systemData, string provisioningState, IDictionary tags, IDictionary properties, string isEnabled, IDictionary evaluators, Trigger trigger, IDictionary serializedAdditionalRawData) - { - Name = name; - Data = data; - Description = description; - SystemData = systemData; - ProvisioningState = provisioningState; - Tags = tags; - Properties = properties; - IsEnabled = isEnabled; - Evaluators = evaluators; - Trigger = trigger; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal EvaluationSchedule() - { - } - - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - public string Name { get; } - /// Data for evaluation. - public ApplicationInsightsConfiguration Data { get; set; } - /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. - public string Description { get; set; } - /// Metadata containing createdBy and modifiedBy information. - public SystemData SystemData { get; } - /// Provisioning State of the evaluation. It is set by service and is read-only. - public string ProvisioningState { get; } - /// Evaluation's tags. Unlike properties, tags are fully mutable. - public IDictionary Tags { get; } - /// Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. - public IDictionary Properties { get; } - /// Enabled status of the evaluation. It is set by service and is read-only. - public string IsEnabled { get; } - /// Evaluators to be used for the evaluation. - public IDictionary Evaluators { get; } - /// - /// Trigger for the evaluation. - /// 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 Trigger Trigger { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTarget.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTarget.Serialization.cs deleted file mode 100644 index 0a8a83d8bae0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTarget.Serialization.cs +++ /dev/null @@ -1,195 +0,0 @@ -// 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 EvaluationTarget : 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(EvaluationTarget)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("systemMessage"u8); - writer.WriteStringValue(SystemMessage); - writer.WritePropertyName("modelConfig"u8); - writer.WriteObjectValue(ModelConfig, options); - if (Optional.IsCollectionDefined(ModelParams)) - { - writer.WritePropertyName("modelParams"u8); - writer.WriteStartObject(); - foreach (var item in ModelParams) - { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } -#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 - } - writer.WriteEndObject(); - } - 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 - } - } - } - - EvaluationTarget 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(EvaluationTarget)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeEvaluationTarget(document.RootElement, options); - } - - internal static EvaluationTarget DeserializeEvaluationTarget(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string systemMessage = default; - TargetModelConfig modelConfig = default; - IDictionary modelParams = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("systemMessage"u8)) - { - systemMessage = property.Value.GetString(); - continue; - } - if (property.NameEquals("modelConfig"u8)) - { - modelConfig = TargetModelConfig.DeserializeTargetModelConfig(property.Value, options); - continue; - } - if (property.NameEquals("modelParams"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - dictionary.Add(property0.Name, null); - } - else - { - dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); - } - } - modelParams = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new EvaluationTarget(systemMessage, modelConfig, modelParams ?? new ChangeTrackingDictionary(), 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(EvaluationTarget)} does not support writing '{options.Format}' format."); - } - } - - EvaluationTarget 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 DeserializeEvaluationTarget(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(EvaluationTarget)} 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 EvaluationTarget FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeEvaluationTarget(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/EvaluationTarget.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTarget.cs deleted file mode 100644 index 0e34a83c1531..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTarget.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Target for the evaluation process. - public partial class EvaluationTarget - { - /// - /// 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 . - /// System message related to the evaluation target. - /// - /// Model configuration for the evaluation. - /// 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 . - /// - /// or is null. - public EvaluationTarget(string systemMessage, TargetModelConfig modelConfig) - { - Argument.AssertNotNull(systemMessage, nameof(systemMessage)); - Argument.AssertNotNull(modelConfig, nameof(modelConfig)); - - SystemMessage = systemMessage; - ModelConfig = modelConfig; - ModelParams = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// System message related to the evaluation target. - /// - /// Model configuration for the evaluation. - /// 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 . - /// - /// A dictionary of parameters for the model. - /// Keeps track of any properties unknown to the library. - internal EvaluationTarget(string systemMessage, TargetModelConfig modelConfig, IDictionary modelParams, IDictionary serializedAdditionalRawData) - { - SystemMessage = systemMessage; - ModelConfig = modelConfig; - ModelParams = modelParams; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal EvaluationTarget() - { - } - - /// System message related to the evaluation target. - public string SystemMessage { get; set; } - /// - /// Model configuration for the evaluation. - /// 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 TargetModelConfig ModelConfig { get; set; } - /// - /// A dictionary of parameters for the model. - /// - /// 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" }. - /// - /// - /// - /// - public IDictionary ModelParams { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationsClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationsClient.cs index 017c3b1d7274..51f2841e4a6f 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationsClient.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationsClient.cs @@ -18,13 +18,10 @@ namespace Azure.AI.Projects /// The Evaluations sub-client. public partial class EvaluationsClient { - private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com/.default" }; + private static readonly string[] AuthorizationScopes = new string[] { "https://ai.azure.com/.default" }; private readonly TokenCredential _tokenCredential; private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; - private readonly string _subscriptionId; - private readonly string _resourceGroupName; - private readonly string _projectName; private readonly string _apiVersion; /// The ClientDiagnostics is used to provide tracing support for the client library. @@ -42,53 +39,54 @@ protected EvaluationsClient() /// The handler for diagnostic messaging in the client. /// The HTTP pipeline for sending and receiving REST requests and responses. /// The token credential to copy. - /// The Azure AI Foundry project endpoint, in the form `https://<azure-region>.api.azureml.ms` or `https://<private-link-guid>.<azure-region>.api.azureml.ms`, where <azure-region> is the Azure region where the project is deployed (e.g. westus) and <private-link-guid> is the GUID of the Enterprise private link. - /// The Azure subscription ID. - /// The name of the Azure Resource Group. - /// The Azure AI Foundry project name. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// /// The API version to use for this operation. - internal EvaluationsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string subscriptionId, string resourceGroupName, string projectName, string apiVersion) + internal EvaluationsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) { ClientDiagnostics = clientDiagnostics; _pipeline = pipeline; _tokenCredential = tokenCredential; _endpoint = endpoint; - _subscriptionId = subscriptionId; - _resourceGroupName = resourceGroupName; - _projectName = projectName; _apiVersion = apiVersion; } - /// Resource read operation template. - /// Identifier of the evaluation. + /// Get an evaluation run by name. + /// Identifier of the evaluation. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetEvaluationAsync(string id, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetEvaluationAsync(string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetEvaluationAsync(id, context).ConfigureAwait(false); + Response response = await GetEvaluationAsync(name, context).ConfigureAwait(false); return Response.FromValue(Evaluation.FromResponse(response), response); } - /// Resource read operation template. - /// Identifier of the evaluation. + /// Get an evaluation run by name. + /// Identifier of the evaluation. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetEvaluation(string id, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetEvaluation(string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetEvaluation(id, context); + Response response = GetEvaluation(name, context); return Response.FromValue(Evaluation.FromResponse(response), response); } /// - /// [Protocol Method] Resource read operation template. + /// [Protocol Method] Get an evaluation run by name. /// /// /// @@ -102,21 +100,22 @@ public virtual Response GetEvaluation(string id, CancellationToken c /// /// /// - /// Identifier of the evaluation. + /// Identifier of the evaluation. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task GetEvaluationAsync(string id, RequestContext context) + /// + public virtual async Task GetEvaluationAsync(string name, RequestContext context) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.GetEvaluation"); scope.Start(); try { - using HttpMessage message = CreateGetEvaluationRequest(id, context); + using HttpMessage message = CreateGetEvaluationRequest(name, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -127,7 +126,7 @@ public virtual async Task GetEvaluationAsync(string id, RequestContext } /// - /// [Protocol Method] Resource read operation template. + /// [Protocol Method] Get an evaluation run by name. /// /// /// @@ -141,21 +140,22 @@ public virtual async Task GetEvaluationAsync(string id, RequestContext /// /// /// - /// Identifier of the evaluation. + /// Identifier of the evaluation. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - public virtual Response GetEvaluation(string id, RequestContext context) + /// + public virtual Response GetEvaluation(string name, RequestContext context) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.GetEvaluation"); scope.Start(); try { - using HttpMessage message = CreateGetEvaluationRequest(id, context); + using HttpMessage message = CreateGetEvaluationRequest(name, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -165,10 +165,11 @@ public virtual Response GetEvaluation(string id, RequestContext context) } } - /// Run the evaluation. - /// Evaluation to run. + /// Creates an evaluation run. + /// Evaluation to be run. /// The cancellation token to use. /// is null. + /// public virtual async Task> CreateAsync(Evaluation evaluation, CancellationToken cancellationToken = default) { Argument.AssertNotNull(evaluation, nameof(evaluation)); @@ -179,10 +180,11 @@ public virtual async Task> CreateAsync(Evaluation evaluatio return Response.FromValue(Evaluation.FromResponse(response), response); } - /// Run the evaluation. - /// Evaluation to run. + /// Creates an evaluation run. + /// Evaluation to be run. /// The cancellation token to use. /// is null. + /// public virtual Response Create(Evaluation evaluation, CancellationToken cancellationToken = default) { Argument.AssertNotNull(evaluation, nameof(evaluation)); @@ -194,7 +196,7 @@ public virtual Response Create(Evaluation evaluation, CancellationTo } /// - /// [Protocol Method] Run the evaluation. + /// [Protocol Method] Creates an evaluation run. /// /// /// @@ -213,6 +215,7 @@ public virtual Response Create(Evaluation evaluation, CancellationTo /// is null. /// Service returned a non-success status code. /// The response returned from the service. + /// public virtual async Task CreateAsync(RequestContent content, RequestContext context = null) { Argument.AssertNotNull(content, nameof(content)); @@ -232,7 +235,7 @@ public virtual async Task CreateAsync(RequestContent content, RequestC } /// - /// [Protocol Method] Run the evaluation. + /// [Protocol Method] Creates an evaluation run. /// /// /// @@ -251,6 +254,7 @@ public virtual async Task CreateAsync(RequestContent content, RequestC /// is null. /// Service returned a non-success status code. /// The response returned from the service. + /// public virtual Response Create(RequestContent content, RequestContext context = null) { Argument.AssertNotNull(content, nameof(content)); @@ -269,220 +273,38 @@ public virtual Response Create(RequestContent content, RequestContext context = } } - /// - /// [Protocol Method] Resource update operation template. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Identifier of the evaluation. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task UpdateAsync(string id, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(id, nameof(id)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.Update"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateRequest(id, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Resource update operation template. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Identifier of the evaluation. - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response Update(string id, RequestContent content, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(id, nameof(id)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.Update"); - scope.Start(); - try - { - using HttpMessage message = CreateUpdateRequest(id, content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Resource read operation template. - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetScheduleAsync(string name, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetScheduleAsync(name, context).ConfigureAwait(false); - return Response.FromValue(EvaluationSchedule.FromResponse(response), response); - } - - /// Resource read operation template. - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetSchedule(string name, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetSchedule(name, context); - return Response.FromValue(EvaluationSchedule.FromResponse(response), response); - } - - /// - /// [Protocol Method] Resource read operation template. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetScheduleAsync(string name, RequestContext context) - { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.GetSchedule"); - scope.Start(); - try - { - using HttpMessage message = CreateGetScheduleRequest(name, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Resource read operation template. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response GetSchedule(string name, RequestContext context) - { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.GetSchedule"); - scope.Start(); - try - { - using HttpMessage message = CreateGetScheduleRequest(name, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Create or replace operation template. - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - /// The resource instance. + /// Creates an agent evaluation run. + /// Agent evaluation to be run. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> CreateOrReplaceScheduleAsync(string name, EvaluationSchedule resource, CancellationToken cancellationToken = default) + /// is null. + /// + public virtual async Task> CreateAgentEvaluationAsync(AgentEvaluationRequest evaluation, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(resource, nameof(resource)); + Argument.AssertNotNull(evaluation, nameof(evaluation)); - using RequestContent content = resource.ToRequestContent(); + using RequestContent content = evaluation.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateOrReplaceScheduleAsync(name, content, context).ConfigureAwait(false); - return Response.FromValue(EvaluationSchedule.FromResponse(response), response); + Response response = await CreateAgentEvaluationAsync(content, context).ConfigureAwait(false); + return Response.FromValue(AgentEvaluation.FromResponse(response), response); } - /// Create or replace operation template. - /// Name of the schedule, which also serves as the unique identifier for the evaluation. - /// The resource instance. + /// Creates an agent evaluation run. + /// Agent evaluation to be run. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response CreateOrReplaceSchedule(string name, EvaluationSchedule resource, CancellationToken cancellationToken = default) + /// is null. + /// + public virtual Response CreateAgentEvaluation(AgentEvaluationRequest evaluation, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(resource, nameof(resource)); + Argument.AssertNotNull(evaluation, nameof(evaluation)); - using RequestContent content = resource.ToRequestContent(); + using RequestContent content = evaluation.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateOrReplaceSchedule(name, content, context); - return Response.FromValue(EvaluationSchedule.FromResponse(response), response); + Response response = CreateAgentEvaluation(content, context); + return Response.FromValue(AgentEvaluation.FromResponse(response), response); } /// - /// [Protocol Method] Create or replace operation template. + /// [Protocol Method] Creates an agent evaluation run. /// /// /// @@ -491,28 +313,26 @@ public virtual Response CreateOrReplaceSchedule(string name, /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// Name of the schedule, which also serves as the unique identifier for the evaluation. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task CreateOrReplaceScheduleAsync(string name, RequestContent content, RequestContext context = null) + /// + public virtual async Task CreateAgentEvaluationAsync(RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.CreateOrReplaceSchedule"); + using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.CreateAgentEvaluation"); scope.Start(); try { - using HttpMessage message = CreateCreateOrReplaceScheduleRequest(name, content, context); + using HttpMessage message = CreateCreateAgentEvaluationRequest(content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -523,7 +343,7 @@ public virtual async Task CreateOrReplaceScheduleAsync(string name, Re } /// - /// [Protocol Method] Create or replace operation template. + /// [Protocol Method] Creates an agent evaluation run. /// /// /// @@ -532,28 +352,26 @@ public virtual async Task CreateOrReplaceScheduleAsync(string name, Re /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// Name of the schedule, which also serves as the unique identifier for the evaluation. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. /// Service returned a non-success status code. /// The response returned from the service. - public virtual Response CreateOrReplaceSchedule(string name, RequestContent content, RequestContext context = null) + /// + public virtual Response CreateAgentEvaluation(RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.CreateOrReplaceSchedule"); + using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.CreateAgentEvaluation"); scope.Start(); try { - using HttpMessage message = CreateCreateOrReplaceScheduleRequest(name, content, context); + using HttpMessage message = CreateCreateAgentEvaluationRequest(content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -563,102 +381,30 @@ public virtual Response CreateOrReplaceSchedule(string name, RequestContent cont } } - /// - /// [Protocol Method] Disable the evaluation schedule. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Name of the evaluation schedule. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task DisableScheduleAsync(string name, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.DisableSchedule"); - scope.Start(); - try - { - using HttpMessage message = CreateDisableScheduleRequest(name, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Disable the evaluation schedule. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Name of the evaluation schedule. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual Response DisableSchedule(string name, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - using var scope = ClientDiagnostics.CreateScope("EvaluationsClient.DisableSchedule"); - scope.Start(); - try - { - using HttpMessage message = CreateDisableScheduleRequest(name, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Resource list operation template. - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. + /// List evaluation runs. /// The cancellation token to use. - public virtual AsyncPageable GetEvaluationsAsync(int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + /// + public virtual AsyncPageable GetEvaluationsAsync(CancellationToken cancellationToken = default) { RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(maxCount, skip, pageSizeHint, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Evaluation.DeserializeEvaluation(e), ClientDiagnostics, _pipeline, "EvaluationsClient.GetEvaluations", "value", "nextLink", maxpagesize, context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Evaluation.DeserializeEvaluation(e), ClientDiagnostics, _pipeline, "EvaluationsClient.GetEvaluations", "value", "nextLink", context); } - /// Resource list operation template. - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. + /// List evaluation runs. /// The cancellation token to use. - public virtual Pageable GetEvaluations(int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + /// + public virtual Pageable GetEvaluations(CancellationToken cancellationToken = default) { RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(maxCount, skip, pageSizeHint, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Evaluation.DeserializeEvaluation(e), ClientDiagnostics, _pipeline, "EvaluationsClient.GetEvaluations", "value", "nextLink", maxpagesize, context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Evaluation.DeserializeEvaluation(e), ClientDiagnostics, _pipeline, "EvaluationsClient.GetEvaluations", "value", "nextLink", context); } /// - /// [Protocol Method] Resource list operation template. + /// [Protocol Method] List evaluation runs /// /// /// @@ -667,26 +413,24 @@ public virtual Pageable GetEvaluations(int? maxCount = null, int? sk /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - public virtual AsyncPageable GetEvaluationsAsync(int? maxCount, int? skip, int? maxpagesize, RequestContext context) + /// + public virtual AsyncPageable GetEvaluationsAsync(RequestContext context) { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(maxCount, skip, pageSizeHint, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "EvaluationsClient.GetEvaluations", "value", "nextLink", maxpagesize, context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "EvaluationsClient.GetEvaluations", "value", "nextLink", context); } /// - /// [Protocol Method] Resource list operation template. + /// [Protocol Method] List evaluation runs /// /// /// @@ -695,240 +439,75 @@ public virtual AsyncPageable GetEvaluationsAsync(int? maxCount, int? /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - public virtual Pageable GetEvaluations(int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(maxCount, skip, pageSizeHint, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "EvaluationsClient.GetEvaluations", "value", "nextLink", maxpagesize, context); - } - - /// Resource list operation template. - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. - /// The cancellation token to use. - public virtual AsyncPageable GetSchedulesAsync(int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + /// + public virtual Pageable GetEvaluations(RequestContext context) { - RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSchedulesRequest(maxCount, skip, pageSizeHint, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSchedulesNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => EvaluationSchedule.DeserializeEvaluationSchedule(e), ClientDiagnostics, _pipeline, "EvaluationsClient.GetSchedules", "value", "nextLink", maxpagesize, context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "EvaluationsClient.GetEvaluations", "value", "nextLink", context); } - /// Resource list operation template. - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. - /// The cancellation token to use. - public virtual Pageable GetSchedules(int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) - { - RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSchedulesRequest(maxCount, skip, pageSizeHint, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSchedulesNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => EvaluationSchedule.DeserializeEvaluationSchedule(e), ClientDiagnostics, _pipeline, "EvaluationsClient.GetSchedules", "value", "nextLink", maxpagesize, context); - } - - /// - /// [Protocol Method] Resource list operation template. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - public virtual AsyncPageable GetSchedulesAsync(int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSchedulesRequest(maxCount, skip, pageSizeHint, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSchedulesNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "EvaluationsClient.GetSchedules", "value", "nextLink", maxpagesize, context); - } - - /// - /// [Protocol Method] Resource list operation template. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The number of result items to return. - /// The number of result items to skip. - /// The maximum number of result items per page. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - public virtual Pageable GetSchedules(int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSchedulesRequest(maxCount, skip, pageSizeHint, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSchedulesNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "EvaluationsClient.GetSchedules", "value", "nextLink", maxpagesize, context); - } - - internal HttpMessage CreateGetEvaluationRequest(string id, RequestContext context) + internal HttpMessage CreateGetEvaluationRequest(string name, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); uri.AppendPath("/evaluations/runs/", false); - uri.AppendPath(id, true); + uri.AppendPath(name, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; } - internal HttpMessage CreateCreateRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier201); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/evaluations/runs:run", false); - uri.AppendQuery("apiVersion", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreateGetEvaluationsRequest(int? maxCount, int? skip, int? maxpagesize, RequestContext context) + internal HttpMessage CreateGetEvaluationsRequest(RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); uri.AppendPath("/evaluations/runs", false); uri.AppendQuery("api-version", _apiVersion, true); - if (maxCount != null) - { - uri.AppendQuery("top", maxCount.Value, true); - } - if (skip != null) - { - uri.AppendQuery("skip", skip.Value, true); - } - if (maxpagesize != null) - { - uri.AppendQuery("maxpagesize", maxpagesize.Value, true); - } request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; } - internal HttpMessage CreateUpdateRequest(string id, RequestContent content, RequestContext context) + internal HttpMessage CreateCreateRequest(RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var message = _pipeline.CreateMessage(context, ResponseClassifier201); var request = message.Request; - request.Method = RequestMethod.Patch; + request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/evaluations/runs/", false); - uri.AppendPath(id, true); + uri.AppendPath("/evaluations/runs:run", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Headers.Add("Content-Type", "application/json"); request.Content = content; return message; } - internal HttpMessage CreateGetScheduleRequest(string name, RequestContext context) + internal HttpMessage CreateCreateAgentEvaluationRequest(RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/evaluations/schedules/", false); - uri.AppendPath(name, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateCreateOrReplaceScheduleRequest(string name, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var message = _pipeline.CreateMessage(context, ResponseClassifier201); var request = message.Request; - request.Method = RequestMethod.Put; + request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/evaluations/schedules/", false); - uri.AppendPath(name, true); + uri.AppendPath("/evaluations/runs:runAgent", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -937,92 +516,13 @@ internal HttpMessage CreateCreateOrReplaceScheduleRequest(string name, RequestCo return message; } - internal HttpMessage CreateGetSchedulesRequest(int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/evaluations/schedules", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (maxCount != null) - { - uri.AppendQuery("top", maxCount.Value, true); - } - if (skip != null) - { - uri.AppendQuery("skip", skip.Value, true); - } - if (maxpagesize != null) - { - uri.AppendQuery("maxpagesize", maxpagesize.Value, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateDisableScheduleRequest(string name, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier204); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/evaluations/schedules/", false); - uri.AppendPath(name, true); - uri.AppendPath("/disable", false); - uri.AppendQuery("apiVersion", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetEvaluationsNextPageRequest(string nextLink, int? maxCount, int? skip, int? maxpagesize, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetSchedulesNextPageRequest(string nextLink, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + internal HttpMessage CreateGetEvaluationsNextPageRequest(string nextLink, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); uri.AppendRawNextLink(nextLink, false); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -1044,9 +544,5 @@ internal static RequestContext FromCancellationToken(CancellationToken cancellat private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); private static ResponseClassifier _responseClassifier201; private static ResponseClassifier ResponseClassifier201 => _responseClassifier201 ??= new StatusCodeClassifier(stackalloc ushort[] { 201 }); - private static ResponseClassifier _responseClassifier200201; - private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); - private static ResponseClassifier _responseClassifier204; - private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FieldMapping.Serialization.cs similarity index 52% rename from sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/FieldMapping.Serialization.cs index f3c37ccd79f0..61b92b5733f3 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FieldMapping.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class RecurrenceSchedule : IUtf8JsonSerializable, IJsonModel + public partial class FieldMapping : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,43 +28,51 @@ 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(FieldMapping)} does not support writing '{format}' format."); } - writer.WritePropertyName("hours"u8); + writer.WritePropertyName("contentFields"u8); writer.WriteStartArray(); - foreach (var item in Hours) + foreach (var item in ContentFields) { - writer.WriteNumberValue(item); + writer.WriteStringValue(item); } writer.WriteEndArray(); - writer.WritePropertyName("minutes"u8); - writer.WriteStartArray(); - foreach (var item in Minutes) + if (Optional.IsDefined(FilepathField)) { - writer.WriteNumberValue(item); + writer.WritePropertyName("filepathField"u8); + writer.WriteStringValue(FilepathField); } - writer.WriteEndArray(); - if (Optional.IsCollectionDefined(WeekDays)) + if (Optional.IsDefined(TitleField)) + { + writer.WritePropertyName("titleField"u8); + writer.WriteStringValue(TitleField); + } + if (Optional.IsDefined(UrlField)) { - writer.WritePropertyName("weekDays"u8); + writer.WritePropertyName("urlField"u8); + writer.WriteStringValue(UrlField); + } + if (Optional.IsCollectionDefined(VectorFields)) + { + writer.WritePropertyName("vectorFields"u8); writer.WriteStartArray(); - foreach (var item in WeekDays) + foreach (var item in VectorFields) { - writer.WriteStringValue(item.ToString()); + writer.WriteStringValue(item); } writer.WriteEndArray(); } - if (Optional.IsCollectionDefined(MonthDays)) + if (Optional.IsCollectionDefined(MetadataFields)) { - writer.WritePropertyName("monthDays"u8); + writer.WritePropertyName("metadataFields"u8); writer.WriteStartArray(); - foreach (var item in MonthDays) + foreach (var item in MetadataFields) { - writer.WriteNumberValue(item); + writer.WriteStringValue(item); } writer.WriteEndArray(); } @@ -85,19 +93,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RecurrenceSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FieldMapping IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(FieldMapping)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRecurrenceSchedule(document.RootElement, options); + return DeserializeFieldMapping(document.RootElement, options); } - internal static RecurrenceSchedule DeserializeRecurrenceSchedule(JsonElement element, ModelReaderWriterOptions options = null) + internal static FieldMapping DeserializeFieldMapping(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -105,60 +113,67 @@ internal static RecurrenceSchedule DeserializeRecurrenceSchedule(JsonElement ele { return null; } - IList hours = default; - IList minutes = default; - IList weekDays = default; - IList monthDays = default; + IList contentFields = default; + string filepathField = default; + string titleField = default; + string urlField = default; + IList vectorFields = default; + IList metadataFields = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("hours"u8)) + if (property.NameEquals("contentFields"u8)) { - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(item.GetInt32()); + array.Add(item.GetString()); } - hours = array; + contentFields = array; continue; } - if (property.NameEquals("minutes"u8)) + if (property.NameEquals("filepathField"u8)) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetInt32()); - } - minutes = array; + filepathField = property.Value.GetString(); + continue; + } + if (property.NameEquals("titleField"u8)) + { + titleField = property.Value.GetString(); + continue; + } + if (property.NameEquals("urlField"u8)) + { + urlField = property.Value.GetString(); continue; } - if (property.NameEquals("weekDays"u8)) + if (property.NameEquals("vectorFields"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(new WeekDays(item.GetString())); + array.Add(item.GetString()); } - weekDays = array; + vectorFields = array; continue; } - if (property.NameEquals("monthDays"u8)) + if (property.NameEquals("metadataFields"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(item.GetInt32()); + array.Add(item.GetString()); } - monthDays = array; + metadataFields = array; continue; } if (options.Format != "W") @@ -167,46 +182,53 @@ internal static RecurrenceSchedule DeserializeRecurrenceSchedule(JsonElement ele } } serializedAdditionalRawData = rawDataDictionary; - return new RecurrenceSchedule(hours, minutes, weekDays ?? new ChangeTrackingList(), monthDays ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new FieldMapping( + contentFields, + filepathField, + titleField, + urlField, + vectorFields ?? new ChangeTrackingList(), + metadataFields ?? new ChangeTrackingList(), + serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(FieldMapping)} does not support writing '{options.Format}' format."); } } - RecurrenceSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + FieldMapping IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRecurrenceSchedule(document.RootElement, options); + return DeserializeFieldMapping(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(FieldMapping)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static RecurrenceSchedule FromResponse(Response response) + internal static FieldMapping FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRecurrenceSchedule(document.RootElement); + return DeserializeFieldMapping(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FieldMapping.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FieldMapping.cs new file mode 100644 index 000000000000..d96f7baa2696 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FieldMapping.cs @@ -0,0 +1,98 @@ +// 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 +{ + /// Field mapping configuration class. + public partial class FieldMapping + { + /// + /// 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 . + /// List of fields with text content. + /// is null. + public FieldMapping(IEnumerable contentFields) + { + Argument.AssertNotNull(contentFields, nameof(contentFields)); + + ContentFields = contentFields.ToList(); + VectorFields = new ChangeTrackingList(); + MetadataFields = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of fields with text content. + /// Path of file to be used as a source of text content. + /// Field containing the title of the document. + /// Field containing the url of the document. + /// List of fields with vector content. + /// List of fields with metadata content. + /// Keeps track of any properties unknown to the library. + internal FieldMapping(IList contentFields, string filepathField, string titleField, string urlField, IList vectorFields, IList metadataFields, IDictionary serializedAdditionalRawData) + { + ContentFields = contentFields; + FilepathField = filepathField; + TitleField = titleField; + UrlField = urlField; + VectorFields = vectorFields; + MetadataFields = metadataFields; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FieldMapping() + { + } + + /// List of fields with text content. + public IList ContentFields { get; } + /// Path of file to be used as a source of text content. + public string FilepathField { get; set; } + /// Field containing the title of the document. + public string TitleField { get; set; } + /// Field containing the url of the document. + public string UrlField { get; set; } + /// List of fields with vector content. + public IList VectorFields { get; } + /// List of fields with metadata content. + public IList MetadataFields { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/File.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/File.Serialization.cs deleted file mode 100644 index 84b2ea8f150c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/File.Serialization.cs +++ /dev/null @@ -1,164 +0,0 @@ -// 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 -{ - internal partial class File : 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(File)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(ContentType)) - { - writer.WritePropertyName("contentType"u8); - writer.WriteStringValue(ContentType); - } - if (Optional.IsDefined(Filename)) - { - writer.WritePropertyName("filename"u8); - writer.WriteStringValue(Filename); - } - writer.WritePropertyName("contents"u8); - writer.WriteBase64StringValue(Contents.ToArray(), "D"); - 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 - } - } - } - - File 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(File)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFile(document.RootElement, options); - } - - internal static File DeserializeFile(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string contentType = default; - string filename = default; - BinaryData contents = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("contentType"u8)) - { - contentType = property.Value.GetString(); - continue; - } - if (property.NameEquals("filename"u8)) - { - filename = property.Value.GetString(); - continue; - } - if (property.NameEquals("contents"u8)) - { - contents = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new File(contentType, filename, contents, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(File)} does not support writing '{options.Format}' format."); - } - } - - File 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 DeserializeFile(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(File)} 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 File FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFile(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/File.cs b/sdk/ai/Azure.AI.Projects/src/Generated/File.cs deleted file mode 100644 index 90eb74955fc6..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/File.cs +++ /dev/null @@ -1,184 +0,0 @@ -// 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 file in an HTTP request, response, or multipart payload. - /// - /// Files have a special meaning that the HTTP library understands. When the body of an HTTP request, response, - /// or multipart payload is _effectively_ an instance of `TypeSpec.Http.File` or any type that extends it, the - /// operation is treated as a file upload or download. - /// - /// When using file bodies, the fields of the file model are defined to come from particular locations by default: - /// - /// - `contentType`: The `Content-Type` header of the request, response, or multipart payload (CANNOT be overridden or changed). - /// - `contents`: The body of the request, response, or multipart payload (CANNOT be overridden or changed). - /// - `filename`: The `filename` parameter value of the `Content-Disposition` header of the response or multipart payload - /// (MAY be overridden or changed). - /// - /// A File may be used as a normal structured JSON object in a request or response, if the request specifies an explicit - /// `Content-Type` header. In this case, the entire File model is serialized as if it were any other model. In a JSON payload, - /// it will have a structure like: - /// - /// ``` - /// { - /// "contentType": <string?>, - /// "filename": <string?>, - /// "contents": <string, base64> - /// } - /// ``` - /// - /// The `contentType` _within_ the file defines what media types the data inside the file can be, but if the specification - /// defines a `Content-Type` for the payload as HTTP metadata, that `Content-Type` metadata defines _how the file is - /// serialized_. See the examples below for more information. - /// - /// NOTE: The `filename` and `contentType` fields are optional. Furthermore, the default location of `filename` - /// (`Content-Disposition: <disposition>; filename=<filename>`) is only valid in HTTP responses and multipart payloads. If - /// you wish to send the `filename` in a request, you must use HTTP metadata decorators to describe the location of the - /// `filename` field. You can combine the metadata decorators with `@visibility` to control when the `filename` location - /// is overridden, as shown in the examples below. - /// - internal partial class File - { - /// - /// 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 contents of the file. - /// - /// In file bodies, this value comes from the body of the request, response, or multipart payload. In JSON bodies, - /// this value is serialized as a field in the response. - /// - /// is null. - public File(BinaryData contents) - { - Argument.AssertNotNull(contents, nameof(contents)); - - Contents = contents; - } - - /// Initializes a new instance of . - /// - /// The allowed media (MIME) types of the file contents. - /// - /// In file bodies, this value comes from the `Content-Type` header of the request or response. In JSON bodies, - /// this value is serialized as a field in the response. - /// - /// NOTE: this is not _necessarily_ the same as the `Content-Type` header of the request or response, but - /// it will be for file bodies. It may be different if the file is serialized as a JSON object. It always refers to the - /// _contents_ of the file, and not necessarily the way the file itself is transmitted or serialized. - /// - /// - /// The name of the file, if any. - /// - /// In file bodies, this value comes from the `filename` parameter of the `Content-Disposition` header of the response - /// or multipart payload. In JSON bodies, this value is serialized as a field in the response. - /// - /// NOTE: By default, `filename` cannot be sent in request payloads and can only be sent in responses and multipart - /// payloads, as the `Content-Disposition` header is not valid in requests. If you want to send the `filename` in a request, - /// you must extend the `File` model and override the `filename` property with a different location defined by HTTP metadata - /// decorators. - /// - /// - /// The contents of the file. - /// - /// In file bodies, this value comes from the body of the request, response, or multipart payload. In JSON bodies, - /// this value is serialized as a field in the response. - /// - /// Keeps track of any properties unknown to the library. - internal File(string contentType, string filename, BinaryData contents, IDictionary serializedAdditionalRawData) - { - ContentType = contentType; - Filename = filename; - Contents = contents; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal File() - { - } - - /// - /// The allowed media (MIME) types of the file contents. - /// - /// In file bodies, this value comes from the `Content-Type` header of the request or response. In JSON bodies, - /// this value is serialized as a field in the response. - /// - /// NOTE: this is not _necessarily_ the same as the `Content-Type` header of the request or response, but - /// it will be for file bodies. It may be different if the file is serialized as a JSON object. It always refers to the - /// _contents_ of the file, and not necessarily the way the file itself is transmitted or serialized. - /// - public string ContentType { get; set; } - /// - /// The name of the file, if any. - /// - /// In file bodies, this value comes from the `filename` parameter of the `Content-Disposition` header of the response - /// or multipart payload. In JSON bodies, this value is serialized as a field in the response. - /// - /// NOTE: By default, `filename` cannot be sent in request payloads and can only be sent in responses and multipart - /// payloads, as the `Content-Disposition` header is not valid in requests. If you want to send the `filename` in a request, - /// you must extend the `File` model and override the `filename` property with a different location defined by HTTP metadata - /// decorators. - /// - public string Filename { get; set; } - /// - /// The contents of the file. - /// - /// In file bodies, this value comes from the body of the request, response, or multipart payload. In JSON bodies, - /// this value is serialized as a field in the response. - /// - /// To assign a byte[] to this property use . - /// The byte[] will be serialized to a Base64 encoded string. - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) - /// Creates a payload of "AQID". - /// - /// - /// - /// - public BinaryData Contents { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateThreadRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileDatasetVersion.Serialization.cs similarity index 50% rename from sdk/ai/Azure.AI.Projects/src/Generated/UpdateThreadRequest.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/FileDatasetVersion.Serialization.cs index 4b4b14c9c658..2c1e1d12fb2f 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateThreadRequest.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FileDatasetVersion.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class UpdateThreadRequest : IUtf8JsonSerializable, IJsonModel + public partial class FileDatasetVersion : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,74 +26,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// The JSON writer. /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(FileDatasetVersion)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ToolResources)) - { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } + base.JsonModelWriteCore(writer, options); } - UpdateThreadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FileDatasetVersion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(FileDatasetVersion)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUpdateThreadRequest(document.RootElement, options); + return DeserializeFileDatasetVersion(document.RootElement, options); } - internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement element, ModelReaderWriterOptions options = null) + internal static FileDatasetVersion DeserializeFileDatasetVersion(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -101,23 +57,64 @@ internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement e { return null; } - ToolResources toolResources = default; - IReadOnlyDictionary metadata = default; + string dataUri = default; + DatasetType type = default; + bool? isReference = default; + string connectionName = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("tool_resources"u8)) + if (property.NameEquals("dataUri"u8)) + { + dataUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new DatasetType(property.Value.GetString()); + continue; + } + if (property.NameEquals("isReference"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { - toolResources = null; continue; } - toolResources = ToolResources.DeserializeToolResources(property.Value, options); + isReference = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); continue; } - if (property.NameEquals("metadata"u8)) + if (property.NameEquals("tags"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -128,7 +125,7 @@ internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement e { dictionary.Add(property0.Name, property0.Value.GetString()); } - metadata = dictionary; + tags = dictionary; continue; } if (options.Format != "W") @@ -137,50 +134,60 @@ internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement e } } serializedAdditionalRawData = rawDataDictionary; - return new UpdateThreadRequest(toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new FileDatasetVersion( + dataUri, + type, + isReference, + connectionName, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(FileDatasetVersion)} does not support writing '{options.Format}' format."); } } - UpdateThreadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + FileDatasetVersion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateThreadRequest(document.RootElement, options); + return DeserializeFileDatasetVersion(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(FileDatasetVersion)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static UpdateThreadRequest FromResponse(Response response) + internal static new FileDatasetVersion FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateThreadRequest(document.RootElement); + return DeserializeFileDatasetVersion(document.RootElement); } /// Convert into a . - internal virtual RequestContent ToRequestContent() + internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileDatasetVersion.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileDatasetVersion.cs new file mode 100644 index 000000000000..b71b168e600b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FileDatasetVersion.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// FileDatasetVersion Definition. + public partial class FileDatasetVersion : DatasetVersion + { + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// is null. + public FileDatasetVersion(string dataUri) : base(dataUri) + { + Argument.AssertNotNull(dataUri, nameof(dataUri)); + + Type = DatasetType.UriFile; + } + + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal FileDatasetVersion(string dataUri, DatasetType type, bool? isReference, string connectionName, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) : base(dataUri, type, isReference, connectionName, id, name, version, description, tags, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal FileDatasetVersion() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchRankingOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchRankingOptions.Serialization.cs deleted file mode 100644 index c7f638392544..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchRankingOptions.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 FileSearchRankingOptions : 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(FileSearchRankingOptions)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("ranker"u8); - writer.WriteStringValue(Ranker); - writer.WritePropertyName("score_threshold"u8); - writer.WriteNumberValue(ScoreThreshold); - 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 - } - } - } - - FileSearchRankingOptions 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(FileSearchRankingOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileSearchRankingOptions(document.RootElement, options); - } - - internal static FileSearchRankingOptions DeserializeFileSearchRankingOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string ranker = default; - float scoreThreshold = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("ranker"u8)) - { - ranker = property.Value.GetString(); - continue; - } - if (property.NameEquals("score_threshold"u8)) - { - scoreThreshold = property.Value.GetSingle(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new FileSearchRankingOptions(ranker, scoreThreshold, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support writing '{options.Format}' format."); - } - } - - FileSearchRankingOptions 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 DeserializeFileSearchRankingOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileSearchRankingOptions)} 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 FileSearchRankingOptions FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFileSearchRankingOptions(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/FileSearchRankingOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchRankingOptions.cs deleted file mode 100644 index ca7922f55151..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchRankingOptions.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Ranking options for file search. - public partial class FileSearchRankingOptions - { - /// - /// 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 . - /// File search ranker. - /// Ranker search threshold. - /// is null. - public FileSearchRankingOptions(string ranker, float scoreThreshold) - { - Argument.AssertNotNull(ranker, nameof(ranker)); - - Ranker = ranker; - ScoreThreshold = scoreThreshold; - } - - /// Initializes a new instance of . - /// File search ranker. - /// Ranker search threshold. - /// Keeps track of any properties unknown to the library. - internal FileSearchRankingOptions(string ranker, float scoreThreshold, IDictionary serializedAdditionalRawData) - { - Ranker = ranker; - ScoreThreshold = scoreThreshold; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal FileSearchRankingOptions() - { - } - - /// File search ranker. - public string Ranker { get; set; } - /// Ranker search threshold. - public float ScoreThreshold { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContent.cs deleted file mode 100644 index 657101f969fe..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContent.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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 file search result content object. - public partial class FileSearchToolCallContent - { - /// - /// 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 text content of the file. - /// is null. - internal FileSearchToolCallContent(string text) - { - Argument.AssertNotNull(text, nameof(text)); - - Text = text; - } - - /// Initializes a new instance of . - /// The type of the content. - /// The text content of the file. - /// Keeps track of any properties unknown to the library. - internal FileSearchToolCallContent(FileSearchToolCallContentType type, string text, IDictionary serializedAdditionalRawData) - { - Type = type; - Text = text; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal FileSearchToolCallContent() - { - } - - /// The type of the content. - public FileSearchToolCallContentType Type { get; } = FileSearchToolCallContentType.Text; - - /// The text content of the file. - public string Text { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContentType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContentType.cs deleted file mode 100644 index 177f40ed440f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContentType.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The FileSearchToolCallContent_type. - public readonly partial struct FileSearchToolCallContentType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public FileSearchToolCallContentType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string TextValue = "text"; - - /// text. - public static FileSearchToolCallContentType Text { get; } = new FileSearchToolCallContentType(TextValue); - /// Determines if two values are the same. - public static bool operator ==(FileSearchToolCallContentType left, FileSearchToolCallContentType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(FileSearchToolCallContentType left, FileSearchToolCallContentType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator FileSearchToolCallContentType(string value) => new FileSearchToolCallContentType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FileSearchToolCallContentType other && Equals(other); - /// - public bool Equals(FileSearchToolCallContentType 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/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinition.Serialization.cs deleted file mode 100644 index 7848398bb734..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinition.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// 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 FileSearchToolDefinition : 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(FileSearchToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - } - - FileSearchToolDefinition 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(FileSearchToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileSearchToolDefinition(document.RootElement, options); - } - - internal static FileSearchToolDefinition DeserializeFileSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - FileSearchToolDefinitionDetails fileSearch = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_search"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = FileSearchToolDefinitionDetails.DeserializeFileSearchToolDefinitionDetails(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 FileSearchToolDefinition(type, serializedAdditionalRawData, fileSearch); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - FileSearchToolDefinition 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 DeserializeFileSearchToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileSearchToolDefinition)} 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 FileSearchToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFileSearchToolDefinition(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/FileSearchToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinition.cs deleted file mode 100644 index 1a1015fb4e16..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinition.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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 file search tool as used to configure an agent. - public partial class FileSearchToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - public FileSearchToolDefinition() - { - Type = "file_search"; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// Options overrides for the file search tool. - internal FileSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, FileSearchToolDefinitionDetails fileSearch) : base(type, serializedAdditionalRawData) - { - FileSearch = fileSearch; - } - - /// Options overrides for the file search tool. - public FileSearchToolDefinitionDetails FileSearch { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs deleted file mode 100644 index 88abc77cb4da..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs +++ /dev/null @@ -1,164 +0,0 @@ -// 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 FileSearchToolDefinitionDetails : 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(FileSearchToolDefinitionDetails)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(MaxNumResults)) - { - writer.WritePropertyName("max_num_results"u8); - writer.WriteNumberValue(MaxNumResults.Value); - } - if (Optional.IsDefined(RankingOptions)) - { - writer.WritePropertyName("ranking_options"u8); - writer.WriteObjectValue(RankingOptions, options); - } - 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 - } - } - } - - FileSearchToolDefinitionDetails 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(FileSearchToolDefinitionDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileSearchToolDefinitionDetails(document.RootElement, options); - } - - internal static FileSearchToolDefinitionDetails DeserializeFileSearchToolDefinitionDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int? maxNumResults = default; - FileSearchRankingOptions rankingOptions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("max_num_results"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - maxNumResults = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("ranking_options"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new FileSearchToolDefinitionDetails(maxNumResults, rankingOptions, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support writing '{options.Format}' format."); - } - } - - FileSearchToolDefinitionDetails 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 DeserializeFileSearchToolDefinitionDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} 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 FileSearchToolDefinitionDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFileSearchToolDefinitionDetails(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/FileSearchToolDefinitionDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinitionDetails.cs deleted file mode 100644 index a2445583f91c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolDefinitionDetails.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Options overrides for the file search tool. - public partial class FileSearchToolDefinitionDetails - { - /// - /// 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 . - public FileSearchToolDefinitionDetails() - { - } - - /// Initializes a new instance of . - /// - /// The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. - /// - /// Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. - /// - /// Ranking options for file search. - /// Keeps track of any properties unknown to the library. - internal FileSearchToolDefinitionDetails(int? maxNumResults, FileSearchRankingOptions rankingOptions, IDictionary serializedAdditionalRawData) - { - MaxNumResults = maxNumResults; - RankingOptions = rankingOptions; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. - /// - /// Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. - /// - public int? MaxNumResults { get; set; } - /// Ranking options for file search. - public FileSearchRankingOptions RankingOptions { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolResource.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolResource.cs deleted file mode 100644 index 9dc2301d67ea..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolResource.cs +++ /dev/null @@ -1,85 +0,0 @@ -// 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 set of resources that are used by the `file_search` tool. - public partial class FileSearchToolResource - { - /// - /// 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 . - public FileSearchToolResource() - { - VectorStoreIds = new ChangeTrackingList(); - VectorStores = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// - /// The ID of the vector store attached to this agent. There can be a maximum of 1 vector - /// store attached to the agent. - /// - /// - /// The list of vector store configuration objects from Azure. - /// This list is limited to one element. - /// The only element of this list contains the list of azure asset IDs used by the search tool. - /// - /// Keeps track of any properties unknown to the library. - internal FileSearchToolResource(IList vectorStoreIds, IList vectorStores, IDictionary serializedAdditionalRawData) - { - VectorStoreIds = vectorStoreIds; - VectorStores = vectorStores; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// The ID of the vector store attached to this agent. There can be a maximum of 1 vector - /// store attached to the agent. - /// - public IList VectorStoreIds { get; } - /// - /// The list of vector store configuration objects from Azure. - /// This list is limited to one element. - /// The only element of this list contains the list of azure asset IDs used by the search tool. - /// - public IList VectorStores { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileState.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileState.cs deleted file mode 100644 index 7b3b0dcba332..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileState.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The state of the file. - public readonly partial struct FileState : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public FileState(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string UploadedValue = "uploaded"; - private const string PendingValue = "pending"; - private const string RunningValue = "running"; - private const string ProcessedValue = "processed"; - private const string ErrorValue = "error"; - private const string DeletingValue = "deleting"; - private const string DeletedValue = "deleted"; - - /// - /// The file has been uploaded but it's not yet processed. This state is not returned by Azure OpenAI and exposed only for - /// compatibility. It can be categorized as an inactive state. - /// - public static FileState Uploaded { get; } = new FileState(UploadedValue); - /// The operation was created and is not queued to be processed in the future. It can be categorized as an inactive state. - public static FileState Pending { get; } = new FileState(PendingValue); - /// The operation has started to be processed. It can be categorized as an active state. - public static FileState Running { get; } = new FileState(RunningValue); - /// The operation has successfully processed and is ready for consumption. It can be categorized as a terminal state. - public static FileState Processed { get; } = new FileState(ProcessedValue); - /// The operation has completed processing with a failure and cannot be further consumed. It can be categorized as a terminal state. - public static FileState Error { get; } = new FileState(ErrorValue); - /// - /// The entity is in the process to be deleted. This state is not returned by Azure OpenAI and exposed only for compatibility. - /// It can be categorized as an active state. - /// - public static FileState Deleting { get; } = new FileState(DeletingValue); - /// - /// The entity has been deleted but may still be referenced by other entities predating the deletion. It can be categorized as a - /// terminal state. - /// - public static FileState Deleted { get; } = new FileState(DeletedValue); - /// Determines if two values are the same. - public static bool operator ==(FileState left, FileState right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(FileState left, FileState right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator FileState(string value) => new FileState(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FileState other && Equals(other); - /// - public bool Equals(FileState 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/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FolderDatasetVersion.Serialization.cs similarity index 51% rename from sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunction.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/FolderDatasetVersion.Serialization.cs index 4d1b54f128af..3aebab7381f7 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunction.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FolderDatasetVersion.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class RunStepDeltaFunction : IUtf8JsonSerializable, IJsonModel + public partial class FolderDatasetVersion : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,66 +26,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// The JSON writer. /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(FolderDatasetVersion)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Arguments)) - { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); - } - if (Optional.IsDefined(Output)) - { - if (Output != null) - { - writer.WritePropertyName("output"u8); - writer.WriteStringValue(Output); - } - else - { - writer.WriteNull("output"); - } - } - 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 - } - } + base.JsonModelWriteCore(writer, options); } - RunStepDeltaFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FolderDatasetVersion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(FolderDatasetVersion)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaFunction(document.RootElement, options); + return DeserializeFolderDatasetVersion(document.RootElement, options); } - internal static RunStepDeltaFunction DeserializeRunStepDeltaFunction(JsonElement element, ModelReaderWriterOptions options = null) + internal static FolderDatasetVersion DeserializeFolderDatasetVersion(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -93,31 +57,75 @@ internal static RunStepDeltaFunction DeserializeRunStepDeltaFunction(JsonElement { return null; } + string dataUri = default; + DatasetType type = default; + bool? isReference = default; + string connectionName = default; + string id = default; string name = default; - string arguments = default; - string output = default; + string version = default; + string description = default; + IDictionary tags = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("dataUri"u8)) + { + dataUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new DatasetType(property.Value.GetString()); + continue; + } + if (property.NameEquals("isReference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isReference = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } if (property.NameEquals("name"u8)) { name = property.Value.GetString(); continue; } - if (property.NameEquals("arguments"u8)) + if (property.NameEquals("version"u8)) { - arguments = property.Value.GetString(); + version = property.Value.GetString(); continue; } - if (property.NameEquals("output"u8)) + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { - output = null; continue; } - output = property.Value.GetString(); + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; continue; } if (options.Format != "W") @@ -126,50 +134,60 @@ internal static RunStepDeltaFunction DeserializeRunStepDeltaFunction(JsonElement } } serializedAdditionalRawData = rawDataDictionary; - return new RunStepDeltaFunction(name, arguments, output, serializedAdditionalRawData); + return new FolderDatasetVersion( + dataUri, + type, + isReference, + connectionName, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(FolderDatasetVersion)} does not support writing '{options.Format}' format."); } } - RunStepDeltaFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + FolderDatasetVersion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaFunction(document.RootElement, options); + return DeserializeFolderDatasetVersion(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(FolderDatasetVersion)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static RunStepDeltaFunction FromResponse(Response response) + internal static new FolderDatasetVersion FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaFunction(document.RootElement); + return DeserializeFolderDatasetVersion(document.RootElement); } /// Convert into a . - internal virtual RequestContent ToRequestContent() + internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FolderDatasetVersion.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FolderDatasetVersion.cs new file mode 100644 index 000000000000..11102394c72c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FolderDatasetVersion.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// FileDatasetVersion Definition. + public partial class FolderDatasetVersion : DatasetVersion + { + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// is null. + public FolderDatasetVersion(string dataUri) : base(dataUri) + { + Argument.AssertNotNull(dataUri, nameof(dataUri)); + + Type = DatasetType.UriFolder; + } + + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal FolderDatasetVersion(string dataUri, DatasetType type, bool? isReference, string connectionName, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) : base(dataUri, type, isReference, connectionName, id, name, version, description, tags, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal FolderDatasetVersion() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Frequency.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Frequency.cs deleted file mode 100644 index 8482e6c67836..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Frequency.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Frequency of the schedule - day, week, month, hour, minute. - public readonly partial struct Frequency : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public Frequency(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string MonthValue = "Month"; - private const string WeekValue = "Week"; - private const string DayValue = "Day"; - private const string HourValue = "Hour"; - private const string MinuteValue = "Minute"; - - /// Month. - public static Frequency Month { get; } = new Frequency(MonthValue); - /// Week. - public static Frequency Week { get; } = new Frequency(WeekValue); - /// Day. - public static Frequency Day { get; } = new Frequency(DayValue); - /// Hour. - public static Frequency Hour { get; } = new Frequency(HourValue); - /// Minute. - public static Frequency Minute { get; } = new Frequency(MinuteValue); - /// Determines if two values are the same. - public static bool operator ==(Frequency left, Frequency right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(Frequency left, Frequency right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator Frequency(string value) => new Frequency(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is Frequency other && Equals(other); - /// - public bool Equals(Frequency 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/sdk/ai/Azure.AI.Projects/src/Generated/FunctionName.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FunctionName.Serialization.cs deleted file mode 100644 index 8679f1ce8baa..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FunctionName.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 FunctionName : 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(FunctionName)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - 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 - } - } - } - - FunctionName 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(FunctionName)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFunctionName(document.RootElement, options); - } - - internal static FunctionName DeserializeFunctionName(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new FunctionName(name, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(FunctionName)} does not support writing '{options.Format}' format."); - } - } - - FunctionName 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 DeserializeFunctionName(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FunctionName)} 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 FunctionName FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFunctionName(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/FunctionName.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FunctionName.cs deleted file mode 100644 index f0388befdeda..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FunctionName.cs +++ /dev/null @@ -1,75 +0,0 @@ -// 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 function name that will be used, if using the `function` tool. - public partial class FunctionName - { - /// - /// 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 name of the function to call. - /// is null. - public FunctionName(string name) - { - Argument.AssertNotNull(name, nameof(name)); - - Name = name; - } - - /// Initializes a new instance of . - /// The name of the function to call. - /// Keeps track of any properties unknown to the library. - internal FunctionName(string name, IDictionary serializedAdditionalRawData) - { - Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal FunctionName() - { - } - - /// The name of the function to call. - public string Name { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FunctionToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FunctionToolDefinition.Serialization.cs deleted file mode 100644 index f942730b72b4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FunctionToolDefinition.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 FunctionToolDefinition : 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(FunctionToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(InternalFunction, options); - } - - FunctionToolDefinition 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(FunctionToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFunctionToolDefinition(document.RootElement, options); - } - - internal static FunctionToolDefinition DeserializeFunctionToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalFunctionDefinition function = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("function"u8)) - { - function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(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 FunctionToolDefinition(type, serializedAdditionalRawData, function); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - FunctionToolDefinition 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 DeserializeFunctionToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FunctionToolDefinition)} 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 FunctionToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFunctionToolDefinition(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/FunctionToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FunctionToolDefinition.cs deleted file mode 100644 index f87f3594f991..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FunctionToolDefinition.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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 function tool as used to configure an agent. - public partial class FunctionToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The definition of the concrete function that the function tool should call. - internal FunctionToolDefinition(string type, IDictionary serializedAdditionalRawData, InternalFunctionDefinition internalFunction) : base(type, serializedAdditionalRawData) - { - InternalFunction = internalFunction; - } - - /// Initializes a new instance of for deserialization. - internal FunctionToolDefinition() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/GetAppInsightsResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/GetAppInsightsResponse.cs deleted file mode 100644 index 2eeb98151a61..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/GetAppInsightsResponse.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Response from getting properties of the Application Insights resource. - internal partial class GetAppInsightsResponse - { - /// - /// 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 unique identifier for the resource. - /// The name of the resource. - /// The properties of the resource. - /// , or is null. - internal GetAppInsightsResponse(string id, string name, AppInsightsProperties properties) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(properties, nameof(properties)); - - Id = id; - Name = name; - Properties = properties; - } - - /// Initializes a new instance of . - /// A unique identifier for the resource. - /// The name of the resource. - /// The properties of the resource. - /// Keeps track of any properties unknown to the library. - internal GetAppInsightsResponse(string id, string name, AppInsightsProperties properties, IDictionary serializedAdditionalRawData) - { - Id = id; - Name = name; - Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal GetAppInsightsResponse() - { - } - - /// A unique identifier for the resource. - public string Id { get; } - /// The name of the resource. - public string Name { get; } - /// The properties of the resource. - public AppInsightsProperties Properties { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/GetConnectionWithSecretsRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/GetConnectionWithSecretsRequest.Serialization.cs deleted file mode 100644 index bf3e708a01be..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/GetConnectionWithSecretsRequest.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 -{ - internal partial class GetConnectionWithSecretsRequest : 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(GetConnectionWithSecretsRequest)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("ignored"u8); - writer.WriteStringValue(Ignored); - 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 - } - } - } - - GetConnectionWithSecretsRequest 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(GetConnectionWithSecretsRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetConnectionWithSecretsRequest(document.RootElement, options); - } - - internal static GetConnectionWithSecretsRequest DeserializeGetConnectionWithSecretsRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string ignored = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("ignored"u8)) - { - ignored = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new GetConnectionWithSecretsRequest(ignored, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(GetConnectionWithSecretsRequest)} does not support writing '{options.Format}' format."); - } - } - - GetConnectionWithSecretsRequest 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 DeserializeGetConnectionWithSecretsRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetConnectionWithSecretsRequest)} 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 GetConnectionWithSecretsRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetConnectionWithSecretsRequest(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/GetConnectionWithSecretsRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/GetConnectionWithSecretsRequest.cs deleted file mode 100644 index 24c528083985..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/GetConnectionWithSecretsRequest.cs +++ /dev/null @@ -1,75 +0,0 @@ -// 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 GetConnectionWithSecretsRequest. - internal partial class GetConnectionWithSecretsRequest - { - /// - /// 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 body is ignored. TODO: Can we remove this?. - /// is null. - internal GetConnectionWithSecretsRequest(string ignored) - { - Argument.AssertNotNull(ignored, nameof(ignored)); - - Ignored = ignored; - } - - /// Initializes a new instance of . - /// The body is ignored. TODO: Can we remove this?. - /// Keeps track of any properties unknown to the library. - internal GetConnectionWithSecretsRequest(string ignored, IDictionary serializedAdditionalRawData) - { - Ignored = ignored; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal GetConnectionWithSecretsRequest() - { - } - - /// The body is ignored. TODO: Can we remove this?. - public string Ignored { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/GetWorkspaceResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/GetWorkspaceResponse.Serialization.cs deleted file mode 100644 index c3ade2bf8c57..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/GetWorkspaceResponse.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 GetWorkspaceResponse : 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(GetWorkspaceResponse)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("properties"u8); - writer.WriteObjectValue(Properties, options); - 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 - } - } - } - - GetWorkspaceResponse 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(GetWorkspaceResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetWorkspaceResponse(document.RootElement, options); - } - - internal static GetWorkspaceResponse DeserializeGetWorkspaceResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - string name = default; - WorkspaceProperties properties = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("properties"u8)) - { - properties = WorkspaceProperties.DeserializeWorkspaceProperties(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new GetWorkspaceResponse(id, name, properties, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(GetWorkspaceResponse)} does not support writing '{options.Format}' format."); - } - } - - GetWorkspaceResponse 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 DeserializeGetWorkspaceResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetWorkspaceResponse)} 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 GetWorkspaceResponse FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetWorkspaceResponse(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/GetWorkspaceResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/GetWorkspaceResponse.cs deleted file mode 100644 index 856f903c20c9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/GetWorkspaceResponse.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Response from the Workspace - Get operation. - public partial class GetWorkspaceResponse - { - /// - /// 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 unique identifier for the resource. - /// The name of the resource. - /// The properties of the resource. - /// , or is null. - internal GetWorkspaceResponse(string id, string name, WorkspaceProperties properties) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(properties, nameof(properties)); - - Id = id; - Name = name; - Properties = properties; - } - - /// Initializes a new instance of . - /// A unique identifier for the resource. - /// The name of the resource. - /// The properties of the resource. - /// Keeps track of any properties unknown to the library. - internal GetWorkspaceResponse(string id, string name, WorkspaceProperties properties, IDictionary serializedAdditionalRawData) - { - Id = id; - Name = name; - Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal GetWorkspaceResponse() - { - } - - /// A unique identifier for the resource. - public string Id { get; } - /// The name of the resource. - public string Name { get; } - /// The properties of the resource. - public WorkspaceProperties Properties { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageDetailLevel.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageDetailLevel.cs deleted file mode 100644 index 96fd8c43e7de..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ImageDetailLevel.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Specifies an image's detail level. Can be 'auto', 'low', 'high', or an unknown future value. - public readonly partial struct ImageDetailLevel : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public ImageDetailLevel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string LowValue = "low"; - private const string HighValue = "high"; - - /// Automatically select an appropriate detail level. - public static ImageDetailLevel Auto { get; } = new ImageDetailLevel(AutoValue); - /// Use a lower detail level to reduce bandwidth or cost. - public static ImageDetailLevel Low { get; } = new ImageDetailLevel(LowValue); - /// Use a higher detail level—potentially more resource-intensive. - public static ImageDetailLevel High { get; } = new ImageDetailLevel(HighValue); - /// Determines if two values are the same. - public static bool operator ==(ImageDetailLevel left, ImageDetailLevel right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(ImageDetailLevel left, ImageDetailLevel right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator ImageDetailLevel(string value) => new ImageDetailLevel(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ImageDetailLevel other && Equals(other); - /// - public bool Equals(ImageDetailLevel 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/sdk/ai/Azure.AI.Projects/src/Generated/IncompleteDetailsReason.cs b/sdk/ai/Azure.AI.Projects/src/Generated/IncompleteDetailsReason.cs deleted file mode 100644 index 517961f355be..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/IncompleteDetailsReason.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. - public readonly partial struct IncompleteDetailsReason : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public IncompleteDetailsReason(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string MaxCompletionTokensValue = "max_completion_tokens"; - private const string MaxPromptTokensValue = "max_prompt_tokens"; - - /// Maximum completion tokens exceeded. - public static IncompleteDetailsReason MaxCompletionTokens { get; } = new IncompleteDetailsReason(MaxCompletionTokensValue); - /// Maximum prompt tokens exceeded. - public static IncompleteDetailsReason MaxPromptTokens { get; } = new IncompleteDetailsReason(MaxPromptTokensValue); - /// Determines if two values are the same. - public static bool operator ==(IncompleteDetailsReason left, IncompleteDetailsReason right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(IncompleteDetailsReason left, IncompleteDetailsReason right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator IncompleteDetailsReason(string value) => new IncompleteDetailsReason(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is IncompleteDetailsReason other && Equals(other); - /// - public bool Equals(IncompleteDetailsReason 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/sdk/ai/Azure.AI.Projects/src/Generated/IncompleteRunDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/IncompleteRunDetails.Serialization.cs deleted file mode 100644 index 74cf6371ce62..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/IncompleteRunDetails.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 IncompleteRunDetails : 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(IncompleteRunDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("reason"u8); - writer.WriteStringValue(Reason.ToString()); - 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 - } - } - } - - IncompleteRunDetails 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(IncompleteRunDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeIncompleteRunDetails(document.RootElement, options); - } - - internal static IncompleteRunDetails DeserializeIncompleteRunDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IncompleteDetailsReason reason = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("reason"u8)) - { - reason = new IncompleteDetailsReason(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new IncompleteRunDetails(reason, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(IncompleteRunDetails)} does not support writing '{options.Format}' format."); - } - } - - IncompleteRunDetails 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 DeserializeIncompleteRunDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(IncompleteRunDetails)} 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 IncompleteRunDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeIncompleteRunDetails(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/IncompleteRunDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/IncompleteRunDetails.cs deleted file mode 100644 index 786489fd3369..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/IncompleteRunDetails.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. - public partial class IncompleteRunDetails - { - /// - /// 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 reason why the run is incomplete. This indicates which specific token limit was reached during the run. - internal IncompleteRunDetails(IncompleteDetailsReason reason) - { - Reason = reason; - } - - /// Initializes a new instance of . - /// The reason why the run is incomplete. This indicates which specific token limit was reached during the run. - /// Keeps track of any properties unknown to the library. - internal IncompleteRunDetails(IncompleteDetailsReason reason, IDictionary serializedAdditionalRawData) - { - Reason = reason; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal IncompleteRunDetails() - { - } - - /// The reason why the run is incomplete. This indicates which specific token limit was reached during the run. - public IncompleteDetailsReason Reason { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Index.Serialization.cs similarity index 53% rename from sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/Index.Serialization.cs index a1644cb757af..8b847e79dd40 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Index.Serialization.cs @@ -12,12 +12,12 @@ namespace Azure.AI.Projects { - [PersistableModelProxy(typeof(UnknownOpenApiAuthDetails))] - public partial class OpenApiAuthDetails : IUtf8JsonSerializable, IJsonModel + [PersistableModelProxy(typeof(UnknownIndex))] + public partial class Index : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,14 +28,45 @@ 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(Index)} does not support writing '{format}' format."); } writer.WritePropertyName("type"u8); writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -53,19 +84,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - OpenApiAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + Index IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(Index)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiAuthDetails(document.RootElement, options); + return DeserializeIndex(document.RootElement, options); } - internal static OpenApiAuthDetails DeserializeOpenApiAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) + internal static Index DeserializeIndex(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,51 +108,51 @@ internal static OpenApiAuthDetails DeserializeOpenApiAuthDetails(JsonElement ele { switch (discriminator.GetString()) { - case "anonymous": return OpenApiAnonymousAuthDetails.DeserializeOpenApiAnonymousAuthDetails(element, options); - case "connection": return OpenApiConnectionAuthDetails.DeserializeOpenApiConnectionAuthDetails(element, options); - case "managed_identity": return OpenApiManagedAuthDetails.DeserializeOpenApiManagedAuthDetails(element, options); + case "AzureSearch": return AzureAISearchIndex.DeserializeAzureAISearchIndex(element, options); + case "CosmosDBNoSqlVectorStore": return CosmosDBIndex.DeserializeCosmosDBIndex(element, options); + case "ManagedAzureSearch": return ManagedAzureAISearchIndex.DeserializeManagedAzureAISearchIndex(element, options); } } - return UnknownOpenApiAuthDetails.DeserializeUnknownOpenApiAuthDetails(element, options); + return UnknownIndex.DeserializeUnknownIndex(element, options); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(Index)} does not support writing '{options.Format}' format."); } } - OpenApiAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + Index IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiAuthDetails(document.RootElement, options); + return DeserializeIndex(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(Index)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static OpenApiAuthDetails FromResponse(Response response) + internal static Index FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiAuthDetails(document.RootElement); + return DeserializeIndex(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Index.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Index.cs new file mode 100644 index 000000000000..7724765d65ad --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Index.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Index resource Definition + /// 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 Index + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected Index() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal Index(IndexType type, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Type = type; + Id = id; + Name = name; + Version = version; + Description = description; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of index. + internal IndexType Type { get; set; } + /// Asset ID, a unique identifier for the asset. + public string Id { get; } + /// The name of the resource. + public string Name { get; } + /// The version of the resource. + public string Version { get; } + /// The asset description text. + public string Description { get; set; } + /// Tag dictionary. Tags can be added, removed, and updated. + public IDictionary Tags { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/IndexType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/IndexType.cs new file mode 100644 index 000000000000..ccd901ba0b11 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/IndexType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The IndexType. + internal readonly partial struct IndexType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public IndexType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AzureSearchValue = "AzureSearch"; + private const string CosmosDBValue = "CosmosDBNoSqlVectorStore"; + private const string ManagedAzureSearchValue = "ManagedAzureSearch"; + + /// Azure search. + public static IndexType AzureSearch { get; } = new IndexType(AzureSearchValue); + /// CosmosDB. + public static IndexType CosmosDB { get; } = new IndexType(CosmosDBValue); + /// Managed Azure Search. + public static IndexType ManagedAzureSearch { get; } = new IndexType(ManagedAzureSearchValue); + /// Determines if two values are the same. + public static bool operator ==(IndexType left, IndexType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IndexType left, IndexType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator IndexType(string value) => new IndexType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IndexType other && Equals(other); + /// + public bool Equals(IndexType 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/sdk/ai/Azure.AI.Projects/src/Generated/Indexes.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Indexes.cs new file mode 100644 index 000000000000..476c41d10d74 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Indexes.cs @@ -0,0 +1,625 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects +{ + // Data plane generated sub-client. + /// The Indexes sub-client. + public partial class Indexes + { + private static readonly string[] AuthorizationScopes = new string[] { "https://ai.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Indexes for mocking. + protected Indexes() + { + } + + /// Initializes a new instance of Indexes. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// + /// The API version to use for this operation. + internal Indexes(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get the specific version of the Index. + /// The name of the resource. + /// The specific version id of the Index to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetIndexAsync(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetIndexAsync(name, version, context).ConfigureAwait(false); + return Response.FromValue(Index.FromResponse(response), response); + } + + /// Get the specific version of the Index. + /// The name of the resource. + /// The specific version id of the Index to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetIndex(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetIndex(name, version, context); + return Response.FromValue(Index.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get the specific version of the Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the Index to retrieve. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetIndexAsync(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.GetIndex"); + scope.Start(); + try + { + using HttpMessage message = CreateGetIndexRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get the specific version of the Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the Index to retrieve. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetIndex(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.GetIndex"); + scope.Start(); + try + { + using HttpMessage message = CreateGetIndexRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the specific version of the Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The version of the Index to delete. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteAsync(string name, string version, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the specific version of the Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The version of the Index to delete. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Delete(string name, string version, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new or update an existing Index with the given version id + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the Index to create or replace. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateAsync(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(name, version, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new or update an existing Index with the given version id + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The specific version id of the Index to create or replace. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdate(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(name, version, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List all versions of the given Index. + /// The name of the resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetVersionsAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Index.DeserializeIndex(e), ClientDiagnostics, _pipeline, "Indexes.GetVersions", "value", "nextLink", context); + } + + /// List all versions of the given Index. + /// The name of the resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetVersions(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Index.DeserializeIndex(e), ClientDiagnostics, _pipeline, "Indexes.GetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all versions of the given Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetVersionsAsync(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Indexes.GetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all versions of the given Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the resource. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetVersions(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Indexes.GetVersions", "value", "nextLink", context); + } + + /// List the latest version of each Index. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetIndicesAsync(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetIndicesRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetIndicesNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Index.DeserializeIndex(e), ClientDiagnostics, _pipeline, "Indexes.GetIndices", "value", "nextLink", context); + } + + /// List the latest version of each Index. + /// The cancellation token to use. + /// + public virtual Pageable GetIndices(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetIndicesRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetIndicesNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Index.DeserializeIndex(e), ClientDiagnostics, _pipeline, "Indexes.GetIndices", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the latest version of each Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetIndicesAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetIndicesRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetIndicesNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Indexes.GetIndices", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the latest version of each Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetIndices(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetIndicesRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetIndicesNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Indexes.GetIndices", "value", "nextLink", context); + } + + internal HttpMessage CreateGetVersionsRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetIndicesRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetIndexRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string name, string version, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetVersionsNextPageRequest(string nextLink, string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetIndicesNextPageRequest(string nextLink, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InputData.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InputData.Serialization.cs index cb3327d29e79..b552950e0e96 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InputData.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InputData.Serialization.cs @@ -77,8 +77,7 @@ internal static InputData DeserializeInputData(JsonElement element, ModelReaderW { switch (discriminator.GetString()) { - case "app_insights": return ApplicationInsightsConfiguration.DeserializeApplicationInsightsConfiguration(element, options); - case "dataset": return Dataset.DeserializeDataset(element, options); + case "dataset": return InputDataset.DeserializeInputDataset(element, options); } } return UnknownInputData.DeserializeUnknownInputData(element, options); diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InputData.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InputData.cs index 0e7e1c295373..f709fb641cd9 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InputData.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InputData.cs @@ -11,9 +11,9 @@ namespace Azure.AI.Projects { /// - /// Abstract data class for input data configuration. + /// Abstract data class. /// 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 . /// public abstract partial class InputData { diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Dataset.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InputDataset.Serialization.cs similarity index 67% rename from sdk/ai/Azure.AI.Projects/src/Generated/Dataset.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/InputDataset.Serialization.cs index 1399c69e7b54..ad49f7ef12cc 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Dataset.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InputDataset.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class Dataset : IUtf8JsonSerializable, IJsonModel + public partial class InputDataset : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,10 +28,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions o /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(Dataset)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(InputDataset)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); @@ -39,19 +39,19 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStringValue(Id); } - Dataset IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InputDataset IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(Dataset)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(InputDataset)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDataset(document.RootElement, options); + return DeserializeInputDataset(document.RootElement, options); } - internal static Dataset DeserializeDataset(JsonElement element, ModelReaderWriterOptions options = null) + internal static InputDataset DeserializeInputDataset(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -81,46 +81,46 @@ internal static Dataset DeserializeDataset(JsonElement element, ModelReaderWrite } } serializedAdditionalRawData = rawDataDictionary; - return new Dataset(type, serializedAdditionalRawData, id); + return new InputDataset(type, serializedAdditionalRawData, id); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(Dataset)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(InputDataset)} does not support writing '{options.Format}' format."); } } - Dataset IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + InputDataset IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDataset(document.RootElement, options); + return DeserializeInputDataset(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(Dataset)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(InputDataset)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new Dataset FromResponse(Response response) + internal static new InputDataset FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDataset(document.RootElement); + return DeserializeInputDataset(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Dataset.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InputDataset.cs similarity index 63% rename from sdk/ai/Azure.AI.Projects/src/Generated/Dataset.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/InputDataset.cs index e164284e2eee..888e5f375fa5 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Dataset.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InputDataset.cs @@ -11,12 +11,12 @@ namespace Azure.AI.Projects { /// Dataset as source for evaluation. - public partial class Dataset : InputData + public partial class InputDataset : InputData { - /// Initializes a new instance of . + /// Initializes a new instance of . /// Evaluation input data. /// is null. - public Dataset(string id) + public InputDataset(string id) { Argument.AssertNotNull(id, nameof(id)); @@ -24,17 +24,17 @@ public Dataset(string id) Id = id; } - /// Initializes a new instance of . + /// Initializes a new instance of . /// Type of the data. /// Keeps track of any properties unknown to the library. /// Evaluation input data. - internal Dataset(string type, IDictionary serializedAdditionalRawData, string id) : base(type, serializedAdditionalRawData) + internal InputDataset(string type, IDictionary serializedAdditionalRawData, string id) : base(type, serializedAdditionalRawData) { Id = id; } - /// Initializes a new instance of for deserialization. - internal Dataset() + /// Initializes a new instance of for deserialization. + internal InputDataset() { } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDeletionStatus.Serialization.cs deleted file mode 100644 index e145adf83f8a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDeletionStatus.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 -{ - internal partial class InternalAgentDeletionStatus : 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(InternalAgentDeletionStatus)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - 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 - } - } - } - - InternalAgentDeletionStatus 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(InternalAgentDeletionStatus)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAgentDeletionStatus(document.RootElement, options); - } - - internal static InternalAgentDeletionStatus DeserializeInternalAgentDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - bool deleted = default; - InternalAgentDeletionStatusObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalAgentDeletionStatusObject(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAgentDeletionStatus(id, deleted, @object, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalAgentDeletionStatus)} does not support writing '{options.Format}' format."); - } - } - - InternalAgentDeletionStatus 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 DeserializeInternalAgentDeletionStatus(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAgentDeletionStatus)} 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 InternalAgentDeletionStatus FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalAgentDeletionStatus(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/InternalAgentDeletionStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDeletionStatus.cs deleted file mode 100644 index 7eeef0999788..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDeletionStatus.cs +++ /dev/null @@ -1,85 +0,0 @@ -// 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 status of an agent deletion operation. - internal partial class InternalAgentDeletionStatus - { - /// - /// 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 ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// is null. - internal InternalAgentDeletionStatus(string id, bool deleted) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - Deleted = deleted; - } - - /// Initializes a new instance of . - /// The ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// The object type, which is always 'assistant.deleted'. - /// Keeps track of any properties unknown to the library. - internal InternalAgentDeletionStatus(string id, bool deleted, InternalAgentDeletionStatusObject @object, IDictionary serializedAdditionalRawData) - { - Id = id; - Deleted = deleted; - Object = @object; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalAgentDeletionStatus() - { - } - - /// The ID of the resource specified for deletion. - public string Id { get; } - /// A value indicating whether deletion was successful. - public bool Deleted { get; } - /// The object type, which is always 'assistant.deleted'. - public InternalAgentDeletionStatusObject Object { get; } = InternalAgentDeletionStatusObject.AssistantDeleted; - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDeletionStatusObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDeletionStatusObject.cs deleted file mode 100644 index 00e557b64a84..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDeletionStatusObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The InternalAgentDeletionStatus_object. - internal readonly partial struct InternalAgentDeletionStatusObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public InternalAgentDeletionStatusObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AssistantDeletedValue = "assistant.deleted"; - - /// assistant.deleted. - public static InternalAgentDeletionStatusObject AssistantDeleted { get; } = new InternalAgentDeletionStatusObject(AssistantDeletedValue); - /// Determines if two values are the same. - public static bool operator ==(InternalAgentDeletionStatusObject left, InternalAgentDeletionStatusObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(InternalAgentDeletionStatusObject left, InternalAgentDeletionStatusObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator InternalAgentDeletionStatusObject(string value) => new InternalAgentDeletionStatusObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalAgentDeletionStatusObject other && Equals(other); - /// - public bool Equals(InternalAgentDeletionStatusObject 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/sdk/ai/Azure.AI.Projects/src/Generated/InternalAzureFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAzureFunctionDefinition.Serialization.cs deleted file mode 100644 index e1a6bf019ddc..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAzureFunctionDefinition.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 -{ - internal partial class InternalAzureFunctionDefinition : 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(InternalAzureFunctionDefinition)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(Function, options); - writer.WritePropertyName("input_binding"u8); - writer.WriteObjectValue(InputBinding, options); - writer.WritePropertyName("output_binding"u8); - writer.WriteObjectValue(OutputBinding, options); - 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 - } - } - } - - InternalAzureFunctionDefinition 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(InternalAzureFunctionDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAzureFunctionDefinition(document.RootElement, options); - } - - internal static InternalAzureFunctionDefinition DeserializeInternalAzureFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalFunctionDefinition function = default; - AzureFunctionBinding inputBinding = default; - AzureFunctionBinding outputBinding = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("function"u8)) - { - function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(property.Value, options); - continue; - } - if (property.NameEquals("input_binding"u8)) - { - inputBinding = AzureFunctionBinding.DeserializeAzureFunctionBinding(property.Value, options); - continue; - } - if (property.NameEquals("output_binding"u8)) - { - outputBinding = AzureFunctionBinding.DeserializeAzureFunctionBinding(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureFunctionDefinition(function, inputBinding, outputBinding, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalAzureFunctionDefinition)} does not support writing '{options.Format}' format."); - } - } - - InternalAzureFunctionDefinition 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 DeserializeInternalAzureFunctionDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAzureFunctionDefinition)} 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 InternalAzureFunctionDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalAzureFunctionDefinition(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/InternalAzureFunctionDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAzureFunctionDefinition.cs deleted file mode 100644 index f566ee9d15b9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAzureFunctionDefinition.cs +++ /dev/null @@ -1,89 +0,0 @@ -// 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 definition of Azure function. - internal partial class InternalAzureFunctionDefinition - { - /// - /// 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 definition of azure function and its parameters. - /// Input storage queue. The queue storage trigger runs a function as messages are added to it. - /// Output storage queue. The function writes output to this queue when the input items are processed. - /// , or is null. - public InternalAzureFunctionDefinition(InternalFunctionDefinition function, AzureFunctionBinding inputBinding, AzureFunctionBinding outputBinding) - { - Argument.AssertNotNull(function, nameof(function)); - Argument.AssertNotNull(inputBinding, nameof(inputBinding)); - Argument.AssertNotNull(outputBinding, nameof(outputBinding)); - - Function = function; - InputBinding = inputBinding; - OutputBinding = outputBinding; - } - - /// Initializes a new instance of . - /// The definition of azure function and its parameters. - /// Input storage queue. The queue storage trigger runs a function as messages are added to it. - /// Output storage queue. The function writes output to this queue when the input items are processed. - /// Keeps track of any properties unknown to the library. - internal InternalAzureFunctionDefinition(InternalFunctionDefinition function, AzureFunctionBinding inputBinding, AzureFunctionBinding outputBinding, IDictionary serializedAdditionalRawData) - { - Function = function; - InputBinding = inputBinding; - OutputBinding = outputBinding; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureFunctionDefinition() - { - } - - /// The definition of azure function and its parameters. - public InternalFunctionDefinition Function { get; set; } - /// Input storage queue. The queue storage trigger runs a function as messages are added to it. - public AzureFunctionBinding InputBinding { get; set; } - /// Output storage queue. The function writes output to this queue when the input items are processed. - public AzureFunctionBinding OutputBinding { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs deleted file mode 100644 index 9ba5254421ca..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs +++ /dev/null @@ -1,160 +0,0 @@ -// 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 -{ - internal partial class InternalCodeInterpreterToolCallDetails : 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(InternalCodeInterpreterToolCallDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("input"u8); - writer.WriteStringValue(Input); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) - { - 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 - } - } - } - - InternalCodeInterpreterToolCallDetails 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(InternalCodeInterpreterToolCallDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCodeInterpreterToolCallDetails(document.RootElement, options); - } - - internal static InternalCodeInterpreterToolCallDetails DeserializeInternalCodeInterpreterToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string input = default; - IReadOnlyList outputs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("input"u8)) - { - input = property.Value.GetString(); - continue; - } - if (property.NameEquals("outputs"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepCodeInterpreterToolCallOutput.DeserializeRunStepCodeInterpreterToolCallOutput(item, options)); - } - outputs = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCodeInterpreterToolCallDetails(input, outputs, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallDetails)} does not support writing '{options.Format}' format."); - } - } - - InternalCodeInterpreterToolCallDetails 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 DeserializeInternalCodeInterpreterToolCallDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallDetails)} 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 InternalCodeInterpreterToolCallDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalCodeInterpreterToolCallDetails(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/InternalCodeInterpreterToolCallDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallDetails.cs deleted file mode 100644 index 2a54a1c73402..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallDetails.cs +++ /dev/null @@ -1,95 +0,0 @@ -// 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 -{ - /// The detailed information about a code interpreter invocation by the model. - internal partial class InternalCodeInterpreterToolCallDetails - { - /// - /// 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 input provided by the model to the code interpreter tool. - /// - /// The outputs produced by the code interpreter tool back to the model in response to the tool call. - /// 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 . - /// - /// or is null. - internal InternalCodeInterpreterToolCallDetails(string input, IEnumerable outputs) - { - Argument.AssertNotNull(input, nameof(input)); - Argument.AssertNotNull(outputs, nameof(outputs)); - - Input = input; - Outputs = outputs.ToList(); - } - - /// Initializes a new instance of . - /// The input provided by the model to the code interpreter tool. - /// - /// The outputs produced by the code interpreter tool back to the model in response to the tool call. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal InternalCodeInterpreterToolCallDetails(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) - { - Input = input; - Outputs = outputs; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalCodeInterpreterToolCallDetails() - { - } - - /// The input provided by the model to the code interpreter tool. - public string Input { get; } - /// - /// The outputs produced by the code interpreter tool back to the model in response to the tool call. - /// 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 IReadOnlyList Outputs { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.Serialization.cs deleted file mode 100644 index 6e89264541b9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.Serialization.cs +++ /dev/null @@ -1,138 +0,0 @@ -// 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 -{ - internal partial class InternalConnectionPropertiesAADAuth : 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(InternalConnectionPropertiesAADAuth)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - InternalConnectionPropertiesAADAuth 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(InternalConnectionPropertiesAADAuth)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalConnectionPropertiesAADAuth(document.RootElement, options); - } - - internal static InternalConnectionPropertiesAADAuth DeserializeInternalConnectionPropertiesAADAuth(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AuthenticationType authType = default; - ConnectionType category = default; - string target = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("authType"u8)) - { - authType = property.Value.GetString().ToAuthenticationType(); - continue; - } - if (property.NameEquals("category"u8)) - { - category = new ConnectionType(property.Value.GetString()); - continue; - } - if (property.NameEquals("target"u8)) - { - target = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalConnectionPropertiesAADAuth(authType, category, target, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalConnectionPropertiesAADAuth)} does not support writing '{options.Format}' format."); - } - } - - InternalConnectionPropertiesAADAuth 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 DeserializeInternalConnectionPropertiesAADAuth(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalConnectionPropertiesAADAuth)} 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 InternalConnectionPropertiesAADAuth FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalConnectionPropertiesAADAuth(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/InternalConnectionPropertiesAADAuth.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.cs deleted file mode 100644 index 8e5ae6c65b87..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Connection properties for connections with AAD authentication (aka `Entra ID passthrough`). - internal partial class InternalConnectionPropertiesAADAuth : ConnectionProperties - { - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// is null. - internal InternalConnectionPropertiesAADAuth(ConnectionType category, string target) : base(category, target) - { - Argument.AssertNotNull(target, nameof(target)); - - AuthType = AuthenticationType.EntraId; - } - - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// Category of the connection. - /// The connection URL to be used for this service. - /// Keeps track of any properties unknown to the library. - internal InternalConnectionPropertiesAADAuth(AuthenticationType authType, ConnectionType category, string target, IDictionary serializedAdditionalRawData) : base(authType, category, target, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal InternalConnectionPropertiesAADAuth() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.Serialization.cs deleted file mode 100644 index 66efdd57854f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.Serialization.cs +++ /dev/null @@ -1,138 +0,0 @@ -// 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 InternalConnectionPropertiesCustomAuth : 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(InternalConnectionPropertiesCustomAuth)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - InternalConnectionPropertiesCustomAuth 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(InternalConnectionPropertiesCustomAuth)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalConnectionPropertiesCustomAuth(document.RootElement, options); - } - - internal static InternalConnectionPropertiesCustomAuth DeserializeInternalConnectionPropertiesCustomAuth(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AuthenticationType authType = default; - ConnectionType category = default; - string target = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("authType"u8)) - { - authType = property.Value.GetString().ToAuthenticationType(); - continue; - } - if (property.NameEquals("category"u8)) - { - category = new ConnectionType(property.Value.GetString()); - continue; - } - if (property.NameEquals("target"u8)) - { - target = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalConnectionPropertiesCustomAuth(authType, category, target, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalConnectionPropertiesCustomAuth)} does not support writing '{options.Format}' format."); - } - } - - InternalConnectionPropertiesCustomAuth 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 DeserializeInternalConnectionPropertiesCustomAuth(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalConnectionPropertiesCustomAuth)} 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 InternalConnectionPropertiesCustomAuth FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalConnectionPropertiesCustomAuth(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/InternalConnectionPropertiesCustomAuth.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.cs deleted file mode 100644 index ec5553dbe294..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Connection properties for connections with Custom authentication. - public partial class InternalConnectionPropertiesCustomAuth : ConnectionProperties - { - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// is null. - internal InternalConnectionPropertiesCustomAuth(ConnectionType category, string target) : base(category, target) - { - Argument.AssertNotNull(target, nameof(target)); - - AuthType = AuthenticationType.Custom; - } - - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// Category of the connection. - /// The connection URL to be used for this service. - /// Keeps track of any properties unknown to the library. - internal InternalConnectionPropertiesCustomAuth(AuthenticationType authType, ConnectionType category, string target, IDictionary serializedAdditionalRawData) : base(authType, category, target, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal InternalConnectionPropertiesCustomAuth() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.Serialization.cs deleted file mode 100644 index 014aef5a7676..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.Serialization.cs +++ /dev/null @@ -1,138 +0,0 @@ -// 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 InternalConnectionPropertiesNoAuth : 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(InternalConnectionPropertiesNoAuth)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - InternalConnectionPropertiesNoAuth 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(InternalConnectionPropertiesNoAuth)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalConnectionPropertiesNoAuth(document.RootElement, options); - } - - internal static InternalConnectionPropertiesNoAuth DeserializeInternalConnectionPropertiesNoAuth(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AuthenticationType authType = default; - ConnectionType category = default; - string target = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("authType"u8)) - { - authType = property.Value.GetString().ToAuthenticationType(); - continue; - } - if (property.NameEquals("category"u8)) - { - category = new ConnectionType(property.Value.GetString()); - continue; - } - if (property.NameEquals("target"u8)) - { - target = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalConnectionPropertiesNoAuth(authType, category, target, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalConnectionPropertiesNoAuth)} does not support writing '{options.Format}' format."); - } - } - - InternalConnectionPropertiesNoAuth 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 DeserializeInternalConnectionPropertiesNoAuth(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalConnectionPropertiesNoAuth)} 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 InternalConnectionPropertiesNoAuth FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalConnectionPropertiesNoAuth(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/InternalConnectionPropertiesNoAuth.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.cs deleted file mode 100644 index 75ba735d790d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Connection properties for connections with no authentication. - public partial class InternalConnectionPropertiesNoAuth : ConnectionProperties - { - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// is null. - internal InternalConnectionPropertiesNoAuth(ConnectionType category, string target) : base(category, target) - { - Argument.AssertNotNull(target, nameof(target)); - - AuthType = AuthenticationType.None; - } - - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// Category of the connection. - /// The connection URL to be used for this service. - /// Keeps track of any properties unknown to the library. - internal InternalConnectionPropertiesNoAuth(AuthenticationType authType, ConnectionType category, string target, IDictionary serializedAdditionalRawData) : base(authType, category, target, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal InternalConnectionPropertiesNoAuth() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.Serialization.cs deleted file mode 100644 index 4b957704bcc1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.Serialization.cs +++ /dev/null @@ -1,146 +0,0 @@ -// 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 -{ - internal partial class InternalConnectionPropertiesSASAuth : 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(InternalConnectionPropertiesSASAuth)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("credentials"u8); - writer.WriteObjectValue(Credentials, options); - } - - InternalConnectionPropertiesSASAuth 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(InternalConnectionPropertiesSASAuth)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalConnectionPropertiesSASAuth(document.RootElement, options); - } - - internal static InternalConnectionPropertiesSASAuth DeserializeInternalConnectionPropertiesSASAuth(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - CredentialsSASAuth credentials = default; - AuthenticationType authType = default; - ConnectionType category = default; - string target = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("credentials"u8)) - { - credentials = CredentialsSASAuth.DeserializeCredentialsSASAuth(property.Value, options); - continue; - } - if (property.NameEquals("authType"u8)) - { - authType = property.Value.GetString().ToAuthenticationType(); - continue; - } - if (property.NameEquals("category"u8)) - { - category = new ConnectionType(property.Value.GetString()); - continue; - } - if (property.NameEquals("target"u8)) - { - target = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalConnectionPropertiesSASAuth(authType, category, target, serializedAdditionalRawData, credentials); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalConnectionPropertiesSASAuth)} does not support writing '{options.Format}' format."); - } - } - - InternalConnectionPropertiesSASAuth 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 DeserializeInternalConnectionPropertiesSASAuth(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalConnectionPropertiesSASAuth)} 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 InternalConnectionPropertiesSASAuth FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalConnectionPropertiesSASAuth(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/InternalConnectionPropertiesSASAuth.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.cs deleted file mode 100644 index cf7a52fbbe22..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Connection properties for connections with SAS authentication. - internal partial class InternalConnectionPropertiesSASAuth : ConnectionProperties - { - /// Initializes a new instance of . - /// Category of the connection. - /// The connection URL to be used for this service. - /// Credentials will only be present for authType=ApiKey. - /// or is null. - internal InternalConnectionPropertiesSASAuth(ConnectionType category, string target, CredentialsSASAuth credentials) : base(category, target) - { - Argument.AssertNotNull(target, nameof(target)); - Argument.AssertNotNull(credentials, nameof(credentials)); - - AuthType = AuthenticationType.SAS; - Credentials = credentials; - } - - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// Category of the connection. - /// The connection URL to be used for this service. - /// Keeps track of any properties unknown to the library. - /// Credentials will only be present for authType=ApiKey. - internal InternalConnectionPropertiesSASAuth(AuthenticationType authType, ConnectionType category, string target, IDictionary serializedAdditionalRawData, CredentialsSASAuth credentials) : base(authType, category, target, serializedAdditionalRawData) - { - Credentials = credentials; - } - - /// Initializes a new instance of for deserialization. - internal InternalConnectionPropertiesSASAuth() - { - } - - /// Credentials will only be present for authType=ApiKey. - public CredentialsSASAuth Credentials { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileDeletionStatus.Serialization.cs deleted file mode 100644 index c9f1b6e4fd37..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileDeletionStatus.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 -{ - internal partial class InternalFileDeletionStatus : 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(InternalFileDeletionStatus)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - 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 - } - } - } - - InternalFileDeletionStatus 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(InternalFileDeletionStatus)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFileDeletionStatus(document.RootElement, options); - } - - internal static InternalFileDeletionStatus DeserializeInternalFileDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - bool deleted = default; - InternalFileDeletionStatusObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalFileDeletionStatusObject(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFileDeletionStatus(id, deleted, @object, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalFileDeletionStatus)} does not support writing '{options.Format}' format."); - } - } - - InternalFileDeletionStatus 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 DeserializeInternalFileDeletionStatus(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFileDeletionStatus)} 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 InternalFileDeletionStatus FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalFileDeletionStatus(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/InternalFileDeletionStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileDeletionStatus.cs deleted file mode 100644 index 445d86d04e67..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileDeletionStatus.cs +++ /dev/null @@ -1,85 +0,0 @@ -// 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 status response from a file deletion operation. - internal partial class InternalFileDeletionStatus - { - /// - /// 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 ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// is null. - internal InternalFileDeletionStatus(string id, bool deleted) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - Deleted = deleted; - } - - /// Initializes a new instance of . - /// The ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// The object type, which is always 'file'. - /// Keeps track of any properties unknown to the library. - internal InternalFileDeletionStatus(string id, bool deleted, InternalFileDeletionStatusObject @object, IDictionary serializedAdditionalRawData) - { - Id = id; - Deleted = deleted; - Object = @object; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalFileDeletionStatus() - { - } - - /// The ID of the resource specified for deletion. - public string Id { get; } - /// A value indicating whether deletion was successful. - public bool Deleted { get; } - /// The object type, which is always 'file'. - public InternalFileDeletionStatusObject Object { get; } = InternalFileDeletionStatusObject.File; - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileDeletionStatusObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileDeletionStatusObject.cs deleted file mode 100644 index 2134fdb513f9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileDeletionStatusObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The InternalFileDeletionStatus_object. - internal readonly partial struct InternalFileDeletionStatusObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public InternalFileDeletionStatusObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string FileValue = "file"; - - /// file. - public static InternalFileDeletionStatusObject File { get; } = new InternalFileDeletionStatusObject(FileValue); - /// Determines if two values are the same. - public static bool operator ==(InternalFileDeletionStatusObject left, InternalFileDeletionStatusObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(InternalFileDeletionStatusObject left, InternalFileDeletionStatusObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator InternalFileDeletionStatusObject(string value) => new InternalFileDeletionStatusObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalFileDeletionStatusObject other && Equals(other); - /// - public bool Equals(InternalFileDeletionStatusObject 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/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileListResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileListResponse.Serialization.cs deleted file mode 100644 index bbeeb53b2fbf..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileListResponse.Serialization.cs +++ /dev/null @@ -1,160 +0,0 @@ -// 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 -{ - internal partial class InternalFileListResponse : 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(InternalFileListResponse)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - 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 - } - } - } - - InternalFileListResponse 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(InternalFileListResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFileListResponse(document.RootElement, options); - } - - internal static InternalFileListResponse DeserializeInternalFileListResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalFileListResponseObject @object = default; - IReadOnlyList data = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = new InternalFileListResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(AgentFile.DeserializeAgentFile(item, options)); - } - data = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFileListResponse(@object, data, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalFileListResponse)} does not support writing '{options.Format}' format."); - } - } - - InternalFileListResponse 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 DeserializeInternalFileListResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFileListResponse)} 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 InternalFileListResponse FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalFileListResponse(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/InternalFileListResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileListResponse.cs deleted file mode 100644 index f86f2ab77484..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileListResponse.cs +++ /dev/null @@ -1,81 +0,0 @@ -// 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 -{ - /// The response data from a file list operation. - internal partial class InternalFileListResponse - { - /// - /// 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 files returned for the request. - /// is null. - internal InternalFileListResponse(IEnumerable data) - { - Argument.AssertNotNull(data, nameof(data)); - - Data = data.ToList(); - } - - /// Initializes a new instance of . - /// The object type, which is always 'list'. - /// The files returned for the request. - /// Keeps track of any properties unknown to the library. - internal InternalFileListResponse(InternalFileListResponseObject @object, IReadOnlyList data, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalFileListResponse() - { - } - - /// The object type, which is always 'list'. - public InternalFileListResponseObject Object { get; } = InternalFileListResponseObject.List; - - /// The files returned for the request. - public IReadOnlyList Data { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileListResponseObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileListResponseObject.cs deleted file mode 100644 index 9129c26b86bc..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileListResponseObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The InternalFileListResponse_object. - internal readonly partial struct InternalFileListResponseObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public InternalFileListResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static InternalFileListResponseObject List { get; } = new InternalFileListResponseObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(InternalFileListResponseObject left, InternalFileListResponseObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(InternalFileListResponseObject left, InternalFileListResponseObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator InternalFileListResponseObject(string value) => new InternalFileListResponseObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalFileListResponseObject other && Equals(other); - /// - public bool Equals(InternalFileListResponseObject 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/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionDefinition.Serialization.cs deleted file mode 100644 index 6fcaeb7f07f2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionDefinition.Serialization.cs +++ /dev/null @@ -1,168 +0,0 @@ -// 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 -{ - internal partial class InternalFunctionDefinition : 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(InternalFunctionDefinition)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - writer.WritePropertyName("parameters"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Parameters); -#else - using (JsonDocument document = JsonDocument.Parse(Parameters, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - 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 - } - } - } - - InternalFunctionDefinition 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(InternalFunctionDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFunctionDefinition(document.RootElement, options); - } - - internal static InternalFunctionDefinition DeserializeInternalFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - string description = default; - BinaryData parameters = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("description"u8)) - { - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("parameters"u8)) - { - parameters = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFunctionDefinition(name, description, parameters, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support writing '{options.Format}' format."); - } - } - - InternalFunctionDefinition 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 DeserializeInternalFunctionDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFunctionDefinition)} 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 InternalFunctionDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalFunctionDefinition(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/InternalFunctionDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionDefinition.cs deleted file mode 100644 index e49213f1237b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionDefinition.cs +++ /dev/null @@ -1,115 +0,0 @@ -// 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 function. - internal partial class InternalFunctionDefinition - { - /// - /// 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 name of the function to be called. - /// The parameters the functions accepts, described as a JSON Schema object. - /// or is null. - public InternalFunctionDefinition(string name, BinaryData parameters) - { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(parameters, nameof(parameters)); - - Name = name; - Parameters = parameters; - } - - /// Initializes a new instance of . - /// The name of the function to be called. - /// A description of what the function does, used by the model to choose when and how to call the function. - /// The parameters the functions accepts, described as a JSON Schema object. - /// Keeps track of any properties unknown to the library. - internal InternalFunctionDefinition(string name, string description, BinaryData parameters, IDictionary serializedAdditionalRawData) - { - Name = name; - Description = description; - Parameters = parameters; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalFunctionDefinition() - { - } - - /// The name of the function to be called. - public string Name { get; set; } - /// A description of what the function does, used by the model to choose when and how to call the function. - public string Description { get; set; } - /// - /// The parameters the functions accepts, described as a JSON Schema object. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already 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" }. - /// - /// - /// - /// - public BinaryData Parameters { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageImageFileDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageImageFileDetails.Serialization.cs deleted file mode 100644 index e1fcc47c2499..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageImageFileDetails.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 -{ - internal partial class InternalMessageImageFileDetails : 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(InternalMessageImageFileDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(InternalDetails); - 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 - } - } - } - - InternalMessageImageFileDetails 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(InternalMessageImageFileDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageImageFileDetails(document.RootElement, options); - } - - internal static InternalMessageImageFileDetails DeserializeInternalMessageImageFileDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageImageFileDetails(fileId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalMessageImageFileDetails)} does not support writing '{options.Format}' format."); - } - } - - InternalMessageImageFileDetails 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 DeserializeInternalMessageImageFileDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageImageFileDetails)} 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 InternalMessageImageFileDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalMessageImageFileDetails(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/InternalMessageImageFileDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageImageFileDetails.cs deleted file mode 100644 index 150277d11fba..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageImageFileDetails.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// An image reference, as represented in thread message content. - internal partial class InternalMessageImageFileDetails - { - /// - /// 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 ID for the file associated with this image. - /// is null. - internal InternalMessageImageFileDetails(string internalDetails) - { - Argument.AssertNotNull(internalDetails, nameof(internalDetails)); - - InternalDetails = internalDetails; - } - - /// Initializes a new instance of . - /// The ID for the file associated with this image. - /// Keeps track of any properties unknown to the library. - internal InternalMessageImageFileDetails(string internalDetails, IDictionary serializedAdditionalRawData) - { - InternalDetails = internalDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalMessageImageFileDetails() - { - } - - /// The ID for the file associated with this image. - public string InternalDetails { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextDetails.Serialization.cs deleted file mode 100644 index 8e16af5676c8..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextDetails.Serialization.cs +++ /dev/null @@ -1,160 +0,0 @@ -// 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 -{ - internal partial class InternalMessageTextDetails : 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(InternalMessageTextDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Text); - writer.WritePropertyName("annotations"u8); - writer.WriteStartArray(); - foreach (var item in Annotations) - { - 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 - } - } - } - - InternalMessageTextDetails 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(InternalMessageTextDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageTextDetails(document.RootElement, options); - } - - internal static InternalMessageTextDetails DeserializeInternalMessageTextDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string value = default; - IReadOnlyList annotations = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("value"u8)) - { - value = property.Value.GetString(); - continue; - } - if (property.NameEquals("annotations"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageTextAnnotation.DeserializeMessageTextAnnotation(item, options)); - } - annotations = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageTextDetails(value, annotations, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalMessageTextDetails)} does not support writing '{options.Format}' format."); - } - } - - InternalMessageTextDetails 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 DeserializeInternalMessageTextDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageTextDetails)} 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 InternalMessageTextDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalMessageTextDetails(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/InternalMessageTextDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextDetails.cs deleted file mode 100644 index 67b453a23b4b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextDetails.cs +++ /dev/null @@ -1,95 +0,0 @@ -// 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 -{ - /// The text and associated annotations for a single item of agent thread message content. - internal partial class InternalMessageTextDetails - { - /// - /// 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 text data. - /// - /// A list of annotations associated with this text. - /// 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 . - /// - /// or is null. - internal InternalMessageTextDetails(string text, IEnumerable annotations) - { - Argument.AssertNotNull(text, nameof(text)); - Argument.AssertNotNull(annotations, nameof(annotations)); - - Text = text; - Annotations = annotations.ToList(); - } - - /// Initializes a new instance of . - /// The text data. - /// - /// A list of annotations associated with this text. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal InternalMessageTextDetails(string text, IReadOnlyList annotations, IDictionary serializedAdditionalRawData) - { - Text = text; - Annotations = annotations; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalMessageTextDetails() - { - } - - /// The text data. - public string Text { get; } - /// - /// A list of annotations associated with this text. - /// 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 IReadOnlyList Annotations { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs deleted file mode 100644 index 19d9920b5fc4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 -{ - internal partial class InternalMessageTextFileCitationDetails : 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(InternalMessageTextFileCitationDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - writer.WritePropertyName("quote"u8); - writer.WriteStringValue(Quote); - 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 - } - } - } - - InternalMessageTextFileCitationDetails 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(InternalMessageTextFileCitationDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageTextFileCitationDetails(document.RootElement, options); - } - - internal static InternalMessageTextFileCitationDetails DeserializeInternalMessageTextFileCitationDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - string quote = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("quote"u8)) - { - quote = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageTextFileCitationDetails(fileId, quote, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalMessageTextFileCitationDetails)} does not support writing '{options.Format}' format."); - } - } - - InternalMessageTextFileCitationDetails 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 DeserializeInternalMessageTextFileCitationDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageTextFileCitationDetails)} 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 InternalMessageTextFileCitationDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalMessageTextFileCitationDetails(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/InternalMessageTextFileCitationDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFileCitationDetails.cs deleted file mode 100644 index e61364394d03..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFileCitationDetails.cs +++ /dev/null @@ -1,82 +0,0 @@ -// 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 representation of a file-based text citation, as used in a file-based annotation of text thread message content. - internal partial class InternalMessageTextFileCitationDetails - { - /// - /// 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 ID of the file associated with this citation. - /// The specific quote cited in the associated file. - /// or is null. - internal InternalMessageTextFileCitationDetails(string fileId, string quote) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - Argument.AssertNotNull(quote, nameof(quote)); - - FileId = fileId; - Quote = quote; - } - - /// Initializes a new instance of . - /// The ID of the file associated with this citation. - /// The specific quote cited in the associated file. - /// Keeps track of any properties unknown to the library. - internal InternalMessageTextFileCitationDetails(string fileId, string quote, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Quote = quote; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalMessageTextFileCitationDetails() - { - } - - /// The ID of the file associated with this citation. - public string FileId { get; } - /// The specific quote cited in the associated file. - public string Quote { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs deleted file mode 100644 index 7733481628e8..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 -{ - internal partial class InternalMessageTextFilePathDetails : 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(InternalMessageTextFilePathDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - 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 - } - } - } - - InternalMessageTextFilePathDetails 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(InternalMessageTextFilePathDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageTextFilePathDetails(document.RootElement, options); - } - - internal static InternalMessageTextFilePathDetails DeserializeInternalMessageTextFilePathDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageTextFilePathDetails(fileId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalMessageTextFilePathDetails)} does not support writing '{options.Format}' format."); - } - } - - InternalMessageTextFilePathDetails 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 DeserializeInternalMessageTextFilePathDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageTextFilePathDetails)} 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 InternalMessageTextFilePathDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalMessageTextFilePathDetails(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/InternalMessageTextFilePathDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFilePathDetails.cs deleted file mode 100644 index 2315f125f95e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMessageTextFilePathDetails.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// An encapsulation of an image file ID, as used by message image content. - internal partial class InternalMessageTextFilePathDetails - { - /// - /// 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 ID of the specific file that the citation is from. - /// is null. - internal InternalMessageTextFilePathDetails(string fileId) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - } - - /// Initializes a new instance of . - /// The ID of the specific file that the citation is from. - /// Keeps track of any properties unknown to the library. - internal InternalMessageTextFilePathDetails(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalMessageTextFilePathDetails() - { - } - - /// The ID of the specific file that the citation is from. - public string FileId { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfAgent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfAgent.Serialization.cs deleted file mode 100644 index ba709acdd6eb..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfAgent.Serialization.cs +++ /dev/null @@ -1,190 +0,0 @@ -// 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 -{ - internal partial class InternalOpenAIPageableListOfAgent : 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(InternalOpenAIPageableListOfAgent)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - 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 - } - } - } - - InternalOpenAIPageableListOfAgent 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(InternalOpenAIPageableListOfAgent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalOpenAIPageableListOfAgent(document.RootElement, options); - } - - internal static InternalOpenAIPageableListOfAgent DeserializeInternalOpenAIPageableListOfAgent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenAIPageableListOfAgentObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = new OpenAIPageableListOfAgentObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(Agent.DeserializeAgent(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalOpenAIPageableListOfAgent( - @object, - data, - firstId, - lastId, - hasMore, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfAgent)} does not support writing '{options.Format}' format."); - } - } - - InternalOpenAIPageableListOfAgent 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 DeserializeInternalOpenAIPageableListOfAgent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfAgent)} 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 InternalOpenAIPageableListOfAgent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalOpenAIPageableListOfAgent(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/InternalOpenAIPageableListOfAgent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfAgent.cs deleted file mode 100644 index 84aaa431daf7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfAgent.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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 -{ - /// The response data for a requested list of items. - internal partial class InternalOpenAIPageableListOfAgent - { - /// - /// 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 requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// , or is null. - internal InternalOpenAIPageableListOfAgent(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// Keeps track of any properties unknown to the library. - internal InternalOpenAIPageableListOfAgent(OpenAIPageableListOfAgentObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalOpenAIPageableListOfAgent() - { - } - - /// The object type, which is always list. - public OpenAIPageableListOfAgentObject Object { get; } = OpenAIPageableListOfAgentObject.List; - - /// The requested list of items. - public IReadOnlyList Data { get; } - /// The first ID represented in this list. - public string FirstId { get; } - /// The last ID represented in this list. - public string LastId { get; } - /// A value indicating whether there are additional values available not captured in this list. - public bool HasMore { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfRunStep.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfRunStep.Serialization.cs deleted file mode 100644 index 772ef1a40542..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfRunStep.Serialization.cs +++ /dev/null @@ -1,190 +0,0 @@ -// 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 -{ - internal partial class InternalOpenAIPageableListOfRunStep : 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(InternalOpenAIPageableListOfRunStep)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - 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 - } - } - } - - InternalOpenAIPageableListOfRunStep 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(InternalOpenAIPageableListOfRunStep)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalOpenAIPageableListOfRunStep(document.RootElement, options); - } - - internal static InternalOpenAIPageableListOfRunStep DeserializeInternalOpenAIPageableListOfRunStep(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenAIPageableListOfRunStepObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = new OpenAIPageableListOfRunStepObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStep.DeserializeRunStep(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalOpenAIPageableListOfRunStep( - @object, - data, - firstId, - lastId, - hasMore, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfRunStep)} does not support writing '{options.Format}' format."); - } - } - - InternalOpenAIPageableListOfRunStep 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 DeserializeInternalOpenAIPageableListOfRunStep(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfRunStep)} 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 InternalOpenAIPageableListOfRunStep FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalOpenAIPageableListOfRunStep(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/InternalOpenAIPageableListOfRunStep.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfRunStep.cs deleted file mode 100644 index ce4995ab4380..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfRunStep.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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 -{ - /// The response data for a requested list of items. - internal partial class InternalOpenAIPageableListOfRunStep - { - /// - /// 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 requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// , or is null. - internal InternalOpenAIPageableListOfRunStep(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// Keeps track of any properties unknown to the library. - internal InternalOpenAIPageableListOfRunStep(OpenAIPageableListOfRunStepObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalOpenAIPageableListOfRunStep() - { - } - - /// The object type, which is always list. - public OpenAIPageableListOfRunStepObject Object { get; } = OpenAIPageableListOfRunStepObject.List; - - /// The requested list of items. - public IReadOnlyList Data { get; } - /// The first ID represented in this list. - public string FirstId { get; } - /// The last ID represented in this list. - public string LastId { get; } - /// A value indicating whether there are additional values available not captured in this list. - public bool HasMore { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadMessage.Serialization.cs deleted file mode 100644 index 7daa22d9d59a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadMessage.Serialization.cs +++ /dev/null @@ -1,190 +0,0 @@ -// 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 -{ - internal partial class InternalOpenAIPageableListOfThreadMessage : 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(InternalOpenAIPageableListOfThreadMessage)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - 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 - } - } - } - - InternalOpenAIPageableListOfThreadMessage 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(InternalOpenAIPageableListOfThreadMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalOpenAIPageableListOfThreadMessage(document.RootElement, options); - } - - internal static InternalOpenAIPageableListOfThreadMessage DeserializeInternalOpenAIPageableListOfThreadMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenAIPageableListOfThreadMessageObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = new OpenAIPageableListOfThreadMessageObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ThreadMessage.DeserializeThreadMessage(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalOpenAIPageableListOfThreadMessage( - @object, - data, - firstId, - lastId, - hasMore, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfThreadMessage)} does not support writing '{options.Format}' format."); - } - } - - InternalOpenAIPageableListOfThreadMessage 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 DeserializeInternalOpenAIPageableListOfThreadMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfThreadMessage)} 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 InternalOpenAIPageableListOfThreadMessage FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalOpenAIPageableListOfThreadMessage(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/InternalOpenAIPageableListOfThreadMessage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadMessage.cs deleted file mode 100644 index 7b92140f7189..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadMessage.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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 -{ - /// The response data for a requested list of items. - internal partial class InternalOpenAIPageableListOfThreadMessage - { - /// - /// 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 requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// , or is null. - internal InternalOpenAIPageableListOfThreadMessage(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// Keeps track of any properties unknown to the library. - internal InternalOpenAIPageableListOfThreadMessage(OpenAIPageableListOfThreadMessageObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalOpenAIPageableListOfThreadMessage() - { - } - - /// The object type, which is always list. - public OpenAIPageableListOfThreadMessageObject Object { get; } = OpenAIPageableListOfThreadMessageObject.List; - - /// The requested list of items. - public IReadOnlyList Data { get; } - /// The first ID represented in this list. - public string FirstId { get; } - /// The last ID represented in this list. - public string LastId { get; } - /// A value indicating whether there are additional values available not captured in this list. - public bool HasMore { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadRun.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadRun.Serialization.cs deleted file mode 100644 index 3542f7af6510..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadRun.Serialization.cs +++ /dev/null @@ -1,190 +0,0 @@ -// 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 -{ - internal partial class InternalOpenAIPageableListOfThreadRun : 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(InternalOpenAIPageableListOfThreadRun)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - 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 - } - } - } - - InternalOpenAIPageableListOfThreadRun 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(InternalOpenAIPageableListOfThreadRun)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalOpenAIPageableListOfThreadRun(document.RootElement, options); - } - - internal static InternalOpenAIPageableListOfThreadRun DeserializeInternalOpenAIPageableListOfThreadRun(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenAIPageableListOfThreadRunObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = new OpenAIPageableListOfThreadRunObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ThreadRun.DeserializeThreadRun(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalOpenAIPageableListOfThreadRun( - @object, - data, - firstId, - lastId, - hasMore, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfThreadRun)} does not support writing '{options.Format}' format."); - } - } - - InternalOpenAIPageableListOfThreadRun 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 DeserializeInternalOpenAIPageableListOfThreadRun(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfThreadRun)} 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 InternalOpenAIPageableListOfThreadRun FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalOpenAIPageableListOfThreadRun(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/InternalOpenAIPageableListOfThreadRun.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadRun.cs deleted file mode 100644 index 92d7bde1e0e7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalOpenAIPageableListOfThreadRun.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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 -{ - /// The response data for a requested list of items. - internal partial class InternalOpenAIPageableListOfThreadRun - { - /// - /// 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 requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// , or is null. - internal InternalOpenAIPageableListOfThreadRun(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// Keeps track of any properties unknown to the library. - internal InternalOpenAIPageableListOfThreadRun(OpenAIPageableListOfThreadRunObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalOpenAIPageableListOfThreadRun() - { - } - - /// The object type, which is always list. - public OpenAIPageableListOfThreadRunObject Object { get; } = OpenAIPageableListOfThreadRunObject.List; - - /// The requested list of items. - public IReadOnlyList Data { get; } - /// The first ID represented in this list. - public string FirstId { get; } - /// The last ID represented in this list. - public string LastId { get; } - /// A value indicating whether there are additional values available not captured in this list. - public bool HasMore { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs deleted file mode 100644 index df69554b3412..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 -{ - internal partial class InternalRequiredFunctionToolCallDetails : 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(InternalRequiredFunctionToolCallDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); - 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 - } - } - } - - InternalRequiredFunctionToolCallDetails 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(InternalRequiredFunctionToolCallDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRequiredFunctionToolCallDetails(document.RootElement, options); - } - - internal static InternalRequiredFunctionToolCallDetails DeserializeInternalRequiredFunctionToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - string arguments = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRequiredFunctionToolCallDetails(name, arguments, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCallDetails)} does not support writing '{options.Format}' format."); - } - } - - InternalRequiredFunctionToolCallDetails 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 DeserializeInternalRequiredFunctionToolCallDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCallDetails)} 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 InternalRequiredFunctionToolCallDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalRequiredFunctionToolCallDetails(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/InternalRequiredFunctionToolCallDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalRequiredFunctionToolCallDetails.cs deleted file mode 100644 index 9c17e43e2e0b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalRequiredFunctionToolCallDetails.cs +++ /dev/null @@ -1,82 +0,0 @@ -// 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 detailed information for a function invocation, as provided by a required action invoking a function tool, that includes the name of and arguments to the function. - internal partial class InternalRequiredFunctionToolCallDetails - { - /// - /// 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 name of the function. - /// The arguments to use when invoking the named function, as provided by the model. Arguments are presented as a JSON document that should be validated and parsed for evaluation. - /// or is null. - internal InternalRequiredFunctionToolCallDetails(string name, string arguments) - { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(arguments, nameof(arguments)); - - Name = name; - Arguments = arguments; - } - - /// Initializes a new instance of . - /// The name of the function. - /// The arguments to use when invoking the named function, as provided by the model. Arguments are presented as a JSON document that should be validated and parsed for evaluation. - /// Keeps track of any properties unknown to the library. - internal InternalRequiredFunctionToolCallDetails(string name, string arguments, IDictionary serializedAdditionalRawData) - { - Name = name; - Arguments = arguments; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalRequiredFunctionToolCallDetails() - { - } - - /// The name of the function. - public string Name { get; } - /// The arguments to use when invoking the named function, as provided by the model. Arguments are presented as a JSON document that should be validated and parsed for evaluation. - public string Arguments { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs deleted file mode 100644 index 45f35da0b778..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs +++ /dev/null @@ -1,170 +0,0 @@ -// 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 -{ - internal partial class InternalRunStepFunctionToolCallDetails : 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(InternalRunStepFunctionToolCallDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); - if (Output != null) - { - writer.WritePropertyName("output"u8); - writer.WriteStringValue(Output); - } - else - { - writer.WriteNull("output"); - } - 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 - } - } - } - - InternalRunStepFunctionToolCallDetails 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(InternalRunStepFunctionToolCallDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); - } - - internal static InternalRunStepFunctionToolCallDetails DeserializeInternalRunStepFunctionToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - string arguments = default; - string output = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (property.NameEquals("output"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - output = null; - continue; - } - output = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepFunctionToolCallDetails(name, arguments, output, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support writing '{options.Format}' format."); - } - } - - InternalRunStepFunctionToolCallDetails 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 DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} 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 InternalRunStepFunctionToolCallDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalRunStepFunctionToolCallDetails(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/InternalRunStepFunctionToolCallDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalRunStepFunctionToolCallDetails.cs deleted file mode 100644 index ff1b24bd121c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalRunStepFunctionToolCallDetails.cs +++ /dev/null @@ -1,88 +0,0 @@ -// 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 detailed information about the function called by the model. - internal partial class InternalRunStepFunctionToolCallDetails - { - /// - /// 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 name of the function. - /// The arguments that the model requires are provided to the named function. - /// The output of the function, only populated for function calls that have already have had their outputs submitted. - /// or is null. - internal InternalRunStepFunctionToolCallDetails(string name, string arguments, string output) - { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(arguments, nameof(arguments)); - - Name = name; - Arguments = arguments; - Output = output; - } - - /// Initializes a new instance of . - /// The name of the function. - /// The arguments that the model requires are provided to the named function. - /// The output of the function, only populated for function calls that have already have had their outputs submitted. - /// Keeps track of any properties unknown to the library. - internal InternalRunStepFunctionToolCallDetails(string name, string arguments, string output, IDictionary serializedAdditionalRawData) - { - Name = name; - Arguments = arguments; - Output = output; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalRunStepFunctionToolCallDetails() - { - } - - /// The name of the function. - public string Name { get; } - /// The arguments that the model requires are provided to the named function. - public string Arguments { get; } - /// The output of the function, only populated for function calls that have already have had their outputs submitted. - public string Output { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs deleted file mode 100644 index dd92c38d070e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs +++ /dev/null @@ -1,152 +0,0 @@ -// 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 -{ - internal partial class InternalSubmitToolOutputsDetails : 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(InternalSubmitToolOutputsDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("tool_calls"u8); - writer.WriteStartArray(); - foreach (var item in ToolCalls) - { - 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 - } - } - } - - InternalSubmitToolOutputsDetails 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(InternalSubmitToolOutputsDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalSubmitToolOutputsDetails(document.RootElement, options); - } - - internal static InternalSubmitToolOutputsDetails DeserializeInternalSubmitToolOutputsDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList toolCalls = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("tool_calls"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RequiredToolCall.DeserializeRequiredToolCall(item, options)); - } - toolCalls = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalSubmitToolOutputsDetails(toolCalls, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(InternalSubmitToolOutputsDetails)} does not support writing '{options.Format}' format."); - } - } - - InternalSubmitToolOutputsDetails 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 DeserializeInternalSubmitToolOutputsDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalSubmitToolOutputsDetails)} 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 InternalSubmitToolOutputsDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInternalSubmitToolOutputsDetails(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/InternalSubmitToolOutputsDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalSubmitToolOutputsDetails.cs deleted file mode 100644 index 368d47db64fd..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalSubmitToolOutputsDetails.cs +++ /dev/null @@ -1,88 +0,0 @@ -// 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 -{ - /// The details describing tools that should be called to submit tool outputs. - internal partial class InternalSubmitToolOutputsDetails - { - /// - /// 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 list of tool calls that must be resolved for the agent thread run to continue. - /// 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 . - /// - /// is null. - internal InternalSubmitToolOutputsDetails(IEnumerable toolCalls) - { - Argument.AssertNotNull(toolCalls, nameof(toolCalls)); - - ToolCalls = toolCalls.ToList(); - } - - /// Initializes a new instance of . - /// - /// The list of tool calls that must be resolved for the agent thread run to continue. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal InternalSubmitToolOutputsDetails(IReadOnlyList toolCalls, IDictionary serializedAdditionalRawData) - { - ToolCalls = toolCalls; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalSubmitToolOutputsDetails() - { - } - - /// - /// The list of tool calls that must be resolved for the agent thread run to continue. - /// 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 . - /// - public IReadOnlyList ToolCalls { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ListConnectionsResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ListConnectionsResponse.Serialization.cs deleted file mode 100644 index 3c03bfdb7122..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ListConnectionsResponse.Serialization.cs +++ /dev/null @@ -1,152 +0,0 @@ -// 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 ListConnectionsResponse : 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(ListConnectionsResponse)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("value"u8); - writer.WriteStartArray(); - foreach (var item in Value) - { - 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 - } - } - } - - ListConnectionsResponse 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(ListConnectionsResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeListConnectionsResponse(document.RootElement, options); - } - - internal static ListConnectionsResponse DeserializeListConnectionsResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("value"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ConnectionResponse.DeserializeConnectionResponse(item, options)); - } - value = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ListConnectionsResponse(value, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ListConnectionsResponse)} does not support writing '{options.Format}' format."); - } - } - - ListConnectionsResponse 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 DeserializeListConnectionsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ListConnectionsResponse)} 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 ListConnectionsResponse FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeListConnectionsResponse(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/ListConnectionsResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ListConnectionsResponse.cs deleted file mode 100644 index 7dd047b9eb69..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ListConnectionsResponse.cs +++ /dev/null @@ -1,76 +0,0 @@ -// 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 -{ - /// Response from the list operation. - public partial class ListConnectionsResponse - { - /// - /// 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 list of connection list secrets. - /// is null. - internal ListConnectionsResponse(IEnumerable value) - { - Argument.AssertNotNull(value, nameof(value)); - - Value = value.ToList(); - } - - /// Initializes a new instance of . - /// A list of connection list secrets. - /// Keeps track of any properties unknown to the library. - internal ListConnectionsResponse(IReadOnlyList value, IDictionary serializedAdditionalRawData) - { - Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ListConnectionsResponse() - { - } - - /// A list of connection list secrets. - public IReadOnlyList Value { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ListSortOrder.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ListSortOrder.cs deleted file mode 100644 index 52bbc7987e71..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ListSortOrder.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The available sorting options when requesting a list of response objects. - public readonly partial struct ListSortOrder : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public ListSortOrder(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AscendingValue = "asc"; - private const string DescendingValue = "desc"; - - /// Specifies an ascending sort order. - public static ListSortOrder Ascending { get; } = new ListSortOrder(AscendingValue); - /// Specifies a descending sort order. - public static ListSortOrder Descending { get; } = new ListSortOrder(DescendingValue); - /// Determines if two values are the same. - public static bool operator ==(ListSortOrder left, ListSortOrder right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(ListSortOrder left, ListSortOrder right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator ListSortOrder(string value) => new ListSortOrder(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ListSortOrder other && Equals(other); - /// - public bool Equals(ListSortOrder 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/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.Serialization.cs deleted file mode 100644 index 035ac9f054f4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 MAASModelConfig : 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(MAASModelConfig)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("azureEndpoint"u8); - writer.WriteStringValue(AzureEndpoint); - writer.WritePropertyName("apiKey"u8); - writer.WriteStringValue(ApiKey); - } - - MAASModelConfig 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(MAASModelConfig)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMAASModelConfig(document.RootElement, options); - } - - internal static MAASModelConfig DeserializeMAASModelConfig(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string azureEndpoint = default; - string apiKey = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("azureEndpoint"u8)) - { - azureEndpoint = property.Value.GetString(); - continue; - } - if (property.NameEquals("apiKey"u8)) - { - apiKey = property.Value.GetString(); - 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 MAASModelConfig(type, serializedAdditionalRawData, azureEndpoint, apiKey); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MAASModelConfig)} does not support writing '{options.Format}' format."); - } - } - - MAASModelConfig 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 DeserializeMAASModelConfig(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MAASModelConfig)} 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 MAASModelConfig FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMAASModelConfig(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/MAASModelConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs deleted file mode 100644 index 92712dbc0601..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// MaaS model configuration. The API version would be selected by the service for querying the model. - public partial class MAASModelConfig : TargetModelConfig - { - /// Initializes a new instance of . - /// Endpoint targetURI for MAAS model. - /// API Key for MAAS model. - /// or is null. - public MAASModelConfig(string azureEndpoint, string apiKey) - { - Argument.AssertNotNull(azureEndpoint, nameof(azureEndpoint)); - Argument.AssertNotNull(apiKey, nameof(apiKey)); - - Type = "MAAS"; - AzureEndpoint = azureEndpoint; - ApiKey = apiKey; - } - - /// Initializes a new instance of . - /// Type of the model configuration. - /// Keeps track of any properties unknown to the library. - /// Endpoint targetURI for MAAS model. - /// API Key for MAAS model. - internal MAASModelConfig(string type, IDictionary serializedAdditionalRawData, string azureEndpoint, string apiKey) : base(type, serializedAdditionalRawData) - { - AzureEndpoint = azureEndpoint; - ApiKey = apiKey; - } - - /// Initializes a new instance of for deserialization. - internal MAASModelConfig() - { - } - - /// 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/RunStepSharepointToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ManagedAzureAISearchIndex.Serialization.cs similarity index 56% rename from sdk/ai/Azure.AI.Projects/src/Generated/RunStepSharepointToolCall.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/ManagedAzureAISearchIndex.Serialization.cs index 37a067bc09fd..4f782226d6fb 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepSharepointToolCall.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ManagedAzureAISearchIndex.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class RunStepSharepointToolCall : IUtf8JsonSerializable, IJsonModel + public partial class ManagedAzureAISearchIndex : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,36 +28,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepSharepointToolCall)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(ManagedAzureAISearchIndex)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("sharepoint_grounding"u8); - writer.WriteStartObject(); - foreach (var item in SharePoint) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); + writer.WritePropertyName("vectorStoreId"u8); + writer.WriteStringValue(VectorStoreId); } - RunStepSharepointToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ManagedAzureAISearchIndex IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepSharepointToolCall)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(ManagedAzureAISearchIndex)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepSharepointToolCall(document.RootElement, options); + return DeserializeManagedAzureAISearchIndex(document.RootElement, options); } - internal static RunStepSharepointToolCall DeserializeRunStepSharepointToolCall(JsonElement element, ModelReaderWriterOptions options = null) + internal static ManagedAzureAISearchIndex DeserializeManagedAzureAISearchIndex(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -65,26 +59,25 @@ internal static RunStepSharepointToolCall DeserializeRunStepSharepointToolCall(J { return null; } - IReadOnlyDictionary sharepointGrounding = default; - string type = default; + string vectorStoreId = default; + IndexType type = default; string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("sharepoint_grounding"u8)) + if (property.NameEquals("vectorStoreId"u8)) { - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - sharepointGrounding = dictionary; + vectorStoreId = property.Value.GetString(); continue; } if (property.NameEquals("type"u8)) { - type = property.Value.GetString(); + type = new IndexType(property.Value.GetString()); continue; } if (property.NameEquals("id"u8)) @@ -92,52 +85,89 @@ internal static RunStepSharepointToolCall DeserializeRunStepSharepointToolCall(J id = property.Value.GetString(); continue; } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new RunStepSharepointToolCall(type, id, serializedAdditionalRawData, sharepointGrounding); + return new ManagedAzureAISearchIndex( + type, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData, + vectorStoreId); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RunStepSharepointToolCall)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(ManagedAzureAISearchIndex)} does not support writing '{options.Format}' format."); } } - RunStepSharepointToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + ManagedAzureAISearchIndex IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepSharepointToolCall(document.RootElement, options); + return DeserializeManagedAzureAISearchIndex(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RunStepSharepointToolCall)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(ManagedAzureAISearchIndex)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new RunStepSharepointToolCall FromResponse(Response response) + internal static new ManagedAzureAISearchIndex FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepSharepointToolCall(document.RootElement); + return DeserializeManagedAzureAISearchIndex(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ManagedAzureAISearchIndex.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ManagedAzureAISearchIndex.cs new file mode 100644 index 000000000000..5ba94ebd30f3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ManagedAzureAISearchIndex.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Managed Azure AI Search Index Definition. + public partial class ManagedAzureAISearchIndex : Index + { + /// Initializes a new instance of . + /// Vector store id of managed index. + /// is null. + public ManagedAzureAISearchIndex(string vectorStoreId) + { + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + + Type = IndexType.ManagedAzureSearch; + VectorStoreId = vectorStoreId; + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + /// Vector store id of managed index. + internal ManagedAzureAISearchIndex(IndexType type, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData, string vectorStoreId) : base(type, id, name, version, description, tags, serializedAdditionalRawData) + { + VectorStoreId = vectorStoreId; + } + + /// Initializes a new instance of for deserialization. + internal ManagedAzureAISearchIndex() + { + } + + /// Vector store id of managed index. + public string VectorStoreId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageAttachment.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageAttachment.Serialization.cs deleted file mode 100644 index a207c79f776f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageAttachment.Serialization.cs +++ /dev/null @@ -1,197 +0,0 @@ -// 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 MessageAttachment : 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(MessageAttachment)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (Optional.IsDefined(DataSource)) - { - writer.WritePropertyName("data_source"u8); - writer.WriteObjectValue(DataSource, options); - } - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - if (item == null) - { - writer.WriteNullValue(); - continue; - } -#if NET6_0_OR_GREATER - writer.WriteRawValue(item); -#else - using (JsonDocument document = JsonDocument.Parse(item, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - 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 - } - } - } - - MessageAttachment 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(MessageAttachment)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageAttachment(document.RootElement, options); - } - - internal static MessageAttachment DeserializeMessageAttachment(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - VectorStoreDataSource dataSource = default; - IList tools = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("data_source"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - dataSource = VectorStoreDataSource.DeserializeVectorStoreDataSource(property.Value, options); - continue; - } - if (property.NameEquals("tools"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(BinaryData.FromString(item.GetRawText())); - } - } - tools = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageAttachment(fileId, dataSource, tools, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageAttachment)} does not support writing '{options.Format}' format."); - } - } - - MessageAttachment 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 DeserializeMessageAttachment(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageAttachment)} 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 MessageAttachment FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageAttachment(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/MessageAttachment.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageAttachment.cs deleted file mode 100644 index be25230a7c4c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageAttachment.cs +++ /dev/null @@ -1,121 +0,0 @@ -// 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 -{ - /// This describes to which tools a file has been attached. - public partial class MessageAttachment - { - /// - /// 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 tools to add to this file. - /// is null. - public MessageAttachment(IEnumerable tools) - { - Argument.AssertNotNull(tools, nameof(tools)); - - Tools = tools.ToList(); - } - - /// Initializes a new instance of . - /// The ID of the file to attach to the message. - /// Azure asset ID. - /// The tools to add to this file. - /// Keeps track of any properties unknown to the library. - internal MessageAttachment(string fileId, VectorStoreDataSource dataSource, IList tools, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - DataSource = dataSource; - Tools = tools; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageAttachment() - { - } - - /// The ID of the file to attach to the message. - public string FileId { get; set; } - /// Azure asset ID. - public VectorStoreDataSource DataSource { get; set; } - /// - /// The tools to add to this file. - /// - /// To assign an object to the element of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public IList Tools { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageBlockType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageBlockType.cs deleted file mode 100644 index c39ca285de4d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageBlockType.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Specifies the kind of content block within a message. Could be text, an image file, an external image URL, or an unknown future type. - internal readonly partial struct MessageBlockType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public MessageBlockType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string TextValue = "text"; - private const string ImageFileValue = "image_file"; - private const string ImageUrlValue = "image_url"; - - /// Indicates a block containing text content. - public static MessageBlockType Text { get; } = new MessageBlockType(TextValue); - /// Indicates a block referencing an internally uploaded image file. - public static MessageBlockType ImageFile { get; } = new MessageBlockType(ImageFileValue); - /// Indicates a block referencing an external image URL. - public static MessageBlockType ImageUrl { get; } = new MessageBlockType(ImageUrlValue); - /// Determines if two values are the same. - public static bool operator ==(MessageBlockType left, MessageBlockType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(MessageBlockType left, MessageBlockType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator MessageBlockType(string value) => new MessageBlockType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageBlockType other && Equals(other); - /// - public bool Equals(MessageBlockType 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/sdk/ai/Azure.AI.Projects/src/Generated/MessageContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageContent.Serialization.cs deleted file mode 100644 index 1b20f90b5074..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageContent.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownMessageContent))] - public partial class MessageContent : 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(MessageContent)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - MessageContent 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(MessageContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageContent(document.RootElement, options); - } - - internal static MessageContent DeserializeMessageContent(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 "image_file": return MessageImageFileContent.DeserializeMessageImageFileContent(element, options); - case "text": return MessageTextContent.DeserializeMessageTextContent(element, options); - } - } - return UnknownMessageContent.DeserializeUnknownMessageContent(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{options.Format}' format."); - } - } - - MessageContent 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 DeserializeMessageContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageContent)} 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 MessageContent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageContent(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/MessageDelta.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDelta.Serialization.cs deleted file mode 100644 index 3b46597d62d1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDelta.Serialization.cs +++ /dev/null @@ -1,160 +0,0 @@ -// 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 MessageDelta : 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(MessageDelta)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToString()); - writer.WritePropertyName("content"u8); - writer.WriteStartArray(); - foreach (var item in Content) - { - 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 - } - } - } - - MessageDelta 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(MessageDelta)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDelta(document.RootElement, options); - } - - internal static MessageDelta DeserializeMessageDelta(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageRole role = default; - IReadOnlyList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("role"u8)) - { - role = new MessageRole(property.Value.GetString()); - continue; - } - if (property.NameEquals("content"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageDeltaContent.DeserializeMessageDeltaContent(item, options)); - } - content = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageDelta(role, content, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDelta)} does not support writing '{options.Format}' format."); - } - } - - MessageDelta 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 DeserializeMessageDelta(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDelta)} 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 MessageDelta FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDelta(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/MessageDelta.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDelta.cs deleted file mode 100644 index 764571c6aa11..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDelta.cs +++ /dev/null @@ -1,94 +0,0 @@ -// 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 -{ - /// Represents the typed 'delta' payload within a streaming message delta chunk. - public partial class MessageDelta - { - /// - /// 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 entity that produced the message. - /// - /// The content of the message as an array of text and/or images. - /// 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 . - /// - /// is null. - internal MessageDelta(MessageRole role, IEnumerable content) - { - Argument.AssertNotNull(content, nameof(content)); - - Role = role; - Content = content.ToList(); - } - - /// Initializes a new instance of . - /// The entity that produced the message. - /// - /// The content of the message as an array of text and/or images. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal MessageDelta(MessageRole role, IReadOnlyList content, IDictionary serializedAdditionalRawData) - { - Role = role; - Content = content; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageDelta() - { - } - - /// The entity that produced the message. - public MessageRole Role { get; } - /// - /// The content of the message as an array of text and/or images. - /// 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 IReadOnlyList Content { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaChunk.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaChunk.Serialization.cs deleted file mode 100644 index 1cb2c5eaa99d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaChunk.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 MessageDeltaChunk : 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(MessageDeltaChunk)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("delta"u8); - writer.WriteObjectValue(Delta, options); - 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 - } - } - } - - MessageDeltaChunk 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(MessageDeltaChunk)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaChunk(document.RootElement, options); - } - - internal static MessageDeltaChunk DeserializeMessageDeltaChunk(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - MessageDeltaChunkObject @object = default; - MessageDelta delta = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new MessageDeltaChunkObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("delta"u8)) - { - delta = MessageDelta.DeserializeMessageDelta(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageDeltaChunk(id, @object, delta, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaChunk 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 DeserializeMessageDeltaChunk(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaChunk)} 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 MessageDeltaChunk FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaChunk(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/MessageDeltaChunk.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaChunk.cs deleted file mode 100644 index cf40d797394f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaChunk.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a message delta i.e. any changed fields on a message during streaming. - public partial class MessageDeltaChunk - { - /// - /// 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 identifier of the message, which can be referenced in API endpoints. - /// The delta containing the fields that have changed on the Message. - /// or is null. - internal MessageDeltaChunk(string id, MessageDelta delta) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(delta, nameof(delta)); - - Id = id; - Delta = delta; - } - - /// Initializes a new instance of . - /// The identifier of the message, which can be referenced in API endpoints. - /// The object type, which is always `thread.message.delta`. - /// The delta containing the fields that have changed on the Message. - /// Keeps track of any properties unknown to the library. - internal MessageDeltaChunk(string id, MessageDeltaChunkObject @object, MessageDelta delta, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - Delta = delta; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaChunk() - { - } - - /// The identifier of the message, which can be referenced in API endpoints. - public string Id { get; } - /// The object type, which is always `thread.message.delta`. - public MessageDeltaChunkObject Object { get; } = MessageDeltaChunkObject.ThreadMessageDelta; - - /// The delta containing the fields that have changed on the Message. - public MessageDelta Delta { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaChunkObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaChunkObject.cs deleted file mode 100644 index d21c2b7731b4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaChunkObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The MessageDeltaChunk_object. - public readonly partial struct MessageDeltaChunkObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public MessageDeltaChunkObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ThreadMessageDeltaValue = "thread.message.delta"; - - /// thread.message.delta. - public static MessageDeltaChunkObject ThreadMessageDelta { get; } = new MessageDeltaChunkObject(ThreadMessageDeltaValue); - /// Determines if two values are the same. - public static bool operator ==(MessageDeltaChunkObject left, MessageDeltaChunkObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(MessageDeltaChunkObject left, MessageDeltaChunkObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator MessageDeltaChunkObject(string value) => new MessageDeltaChunkObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageDeltaChunkObject other && Equals(other); - /// - public bool Equals(MessageDeltaChunkObject 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/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaContent.Serialization.cs deleted file mode 100644 index 06b3dbaa6e0b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaContent.Serialization.cs +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownMessageDeltaContent))] - public partial class MessageDeltaContent : 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(MessageDeltaContent)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - MessageDeltaContent 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(MessageDeltaContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaContent(document.RootElement, options); - } - - internal static MessageDeltaContent DeserializeMessageDeltaContent(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 "image_file": return MessageDeltaImageFileContent.DeserializeMessageDeltaImageFileContent(element, options); - case "text": return MessageDeltaTextContent.DeserializeMessageDeltaTextContent(element, options); - } - } - return UnknownMessageDeltaContent.DeserializeUnknownMessageDeltaContent(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaContent 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 DeserializeMessageDeltaContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaContent)} 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 MessageDeltaContent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaContent(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/MessageDeltaContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaContent.cs deleted file mode 100644 index 367980dcb8a0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaContent.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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 abstract base representation of a partial streamed message content payload. - /// 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 MessageDeltaContent - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The index of the content part of the message. - protected MessageDeltaContent(int index) - { - Index = index; - } - - /// Initializes a new instance of . - /// The index of the content part of the message. - /// The type of content for this content part. - /// Keeps track of any properties unknown to the library. - internal MessageDeltaContent(int index, string type, IDictionary serializedAdditionalRawData) - { - Index = index; - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaContent() - { - } - - /// The index of the content part of the message. - public int Index { get; } - /// The type of content for this content part. - internal string Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContent.Serialization.cs deleted file mode 100644 index c0e90a53d7bd..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContent.Serialization.cs +++ /dev/null @@ -1,147 +0,0 @@ -// 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 MessageDeltaImageFileContent : 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(MessageDeltaImageFileContent)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(ImageFile)) - { - writer.WritePropertyName("image_file"u8); - writer.WriteObjectValue(ImageFile, options); - } - } - - MessageDeltaImageFileContent 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(MessageDeltaImageFileContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaImageFileContent(document.RootElement, options); - } - - internal static MessageDeltaImageFileContent DeserializeMessageDeltaImageFileContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageDeltaImageFileContentObject imageFile = default; - int index = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("image_file"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - imageFile = MessageDeltaImageFileContentObject.DeserializeMessageDeltaImageFileContentObject(property.Value, options); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 MessageDeltaImageFileContent(index, type, serializedAdditionalRawData, imageFile); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaImageFileContent 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 DeserializeMessageDeltaImageFileContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} 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 MessageDeltaImageFileContent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaImageFileContent(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/MessageDeltaImageFileContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContent.cs deleted file mode 100644 index 782ee27b4b55..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContent.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a streamed image file content part within a streaming message delta chunk. - public partial class MessageDeltaImageFileContent : MessageDeltaContent - { - /// Initializes a new instance of . - /// The index of the content part of the message. - internal MessageDeltaImageFileContent(int index) : base(index) - { - Type = "image_file"; - } - - /// Initializes a new instance of . - /// The index of the content part of the message. - /// The type of content for this content part. - /// Keeps track of any properties unknown to the library. - /// The image_file data. - internal MessageDeltaImageFileContent(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaImageFileContentObject imageFile) : base(index, type, serializedAdditionalRawData) - { - ImageFile = imageFile; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaImageFileContent() - { - } - - /// The image_file data. - public MessageDeltaImageFileContentObject ImageFile { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs deleted file mode 100644 index 92257c0cadc5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs +++ /dev/null @@ -1,145 +0,0 @@ -// 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 MessageDeltaImageFileContentObject : 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(MessageDeltaImageFileContentObject)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - 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 - } - } - } - - MessageDeltaImageFileContentObject 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(MessageDeltaImageFileContentObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaImageFileContentObject(document.RootElement, options); - } - - internal static MessageDeltaImageFileContentObject DeserializeMessageDeltaImageFileContentObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageDeltaImageFileContentObject(fileId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaImageFileContentObject 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 DeserializeMessageDeltaImageFileContentObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} 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 MessageDeltaImageFileContentObject FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaImageFileContentObject(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/MessageDeltaImageFileContentObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContentObject.cs deleted file mode 100644 index e62ccc339207..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaImageFileContentObject.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents the 'image_file' payload within streaming image file content. - public partial class MessageDeltaImageFileContentObject - { - /// - /// 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 . - internal MessageDeltaImageFileContentObject() - { - } - - /// Initializes a new instance of . - /// The file ID of the image in the message content. - /// Keeps track of any properties unknown to the library. - internal MessageDeltaImageFileContentObject(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The file ID of the image in the message content. - public string FileId { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextAnnotation.Serialization.cs deleted file mode 100644 index 0ebf9a44c4e2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextAnnotation.Serialization.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownMessageDeltaTextAnnotation))] - public partial class MessageDeltaTextAnnotation : 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(MessageDeltaTextAnnotation)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - MessageDeltaTextAnnotation 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(MessageDeltaTextAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); - } - - internal static MessageDeltaTextAnnotation DeserializeMessageDeltaTextAnnotation(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 "file_citation": return MessageDeltaTextFileCitationAnnotation.DeserializeMessageDeltaTextFileCitationAnnotation(element, options); - case "file_path": return MessageDeltaTextFilePathAnnotation.DeserializeMessageDeltaTextFilePathAnnotation(element, options); - case "url_citation": return MessageDeltaTextUrlCitationAnnotation.DeserializeMessageDeltaTextUrlCitationAnnotation(element, options); - } - } - return UnknownMessageDeltaTextAnnotation.DeserializeUnknownMessageDeltaTextAnnotation(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextAnnotation 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 DeserializeMessageDeltaTextAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} 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 MessageDeltaTextAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextAnnotation(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/MessageDeltaTextAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextAnnotation.cs deleted file mode 100644 index f3dea9aa929d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextAnnotation.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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 abstract base representation of a streamed text content part's text annotation. - /// 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 MessageDeltaTextAnnotation - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - protected MessageDeltaTextAnnotation(int index) - { - Index = index; - } - - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The type of the text content annotation. - /// Keeps track of any properties unknown to the library. - internal MessageDeltaTextAnnotation(int index, string type, IDictionary serializedAdditionalRawData) - { - Index = index; - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaTextAnnotation() - { - } - - /// The index of the annotation within a text content part. - public int Index { get; } - /// The type of the text content annotation. - internal string Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContent.Serialization.cs deleted file mode 100644 index a29d76a0c1e1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContent.Serialization.cs +++ /dev/null @@ -1,147 +0,0 @@ -// 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 MessageDeltaTextContent : 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(MessageDeltaTextContent)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(Text)) - { - writer.WritePropertyName("text"u8); - writer.WriteObjectValue(Text, options); - } - } - - MessageDeltaTextContent 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(MessageDeltaTextContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextContent(document.RootElement, options); - } - - internal static MessageDeltaTextContent DeserializeMessageDeltaTextContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageDeltaTextContentObject text = default; - int index = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("text"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - text = MessageDeltaTextContentObject.DeserializeMessageDeltaTextContentObject(property.Value, options); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 MessageDeltaTextContent(index, type, serializedAdditionalRawData, text); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextContent 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 DeserializeMessageDeltaTextContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextContent)} 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 MessageDeltaTextContent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextContent(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/MessageDeltaTextContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContent.cs deleted file mode 100644 index af3ed70f6d9c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContent.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a streamed text content part within a streaming message delta chunk. - public partial class MessageDeltaTextContent : MessageDeltaContent - { - /// Initializes a new instance of . - /// The index of the content part of the message. - internal MessageDeltaTextContent(int index) : base(index) - { - Type = "text"; - } - - /// Initializes a new instance of . - /// The index of the content part of the message. - /// The type of content for this content part. - /// Keeps track of any properties unknown to the library. - /// The text content details. - internal MessageDeltaTextContent(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextContentObject text) : base(index, type, serializedAdditionalRawData) - { - Text = text; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaTextContent() - { - } - - /// The text content details. - public MessageDeltaTextContentObject Text { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContentObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContentObject.cs deleted file mode 100644 index 58f826ce5db7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextContentObject.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents the data of a streamed text content part within a streaming message delta chunk. - public partial class MessageDeltaTextContentObject - { - /// - /// 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 . - internal MessageDeltaTextContentObject() - { - Annotations = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The data that makes up the text. - /// - /// Annotations for the text. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal MessageDeltaTextContentObject(string value, IReadOnlyList annotations, IDictionary serializedAdditionalRawData) - { - Value = value; - Annotations = annotations; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The data that makes up the text. - public string Value { get; } - /// - /// Annotations for the text. - /// 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 IReadOnlyList Annotations { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs deleted file mode 100644 index 47ee6ede6619..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs +++ /dev/null @@ -1,195 +0,0 @@ -// 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 MessageDeltaTextFileCitationAnnotation : 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(MessageDeltaTextFileCitationAnnotation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(FileCitation)) - { - writer.WritePropertyName("file_citation"u8); - writer.WriteObjectValue(FileCitation, options); - } - if (Optional.IsDefined(Text)) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - } - - MessageDeltaTextFileCitationAnnotation 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(MessageDeltaTextFileCitationAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextFileCitationAnnotation(document.RootElement, options); - } - - internal static MessageDeltaTextFileCitationAnnotation DeserializeMessageDeltaTextFileCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageDeltaTextFileCitationAnnotationObject fileCitation = default; - string text = default; - int? startIndex = default; - int? endIndex = default; - int index = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_citation"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileCitation = MessageDeltaTextFileCitationAnnotationObject.DeserializeMessageDeltaTextFileCitationAnnotationObject(property.Value, options); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("start_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 MessageDeltaTextFileCitationAnnotation( - index, - type, - serializedAdditionalRawData, - fileCitation, - text, - startIndex, - endIndex); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextFileCitationAnnotation 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 DeserializeMessageDeltaTextFileCitationAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} 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 MessageDeltaTextFileCitationAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextFileCitationAnnotation(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/MessageDeltaTextFileCitationAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotation.cs deleted file mode 100644 index f22164e3a330..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotation.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a streamed file citation applied to a streaming text content part. - public partial class MessageDeltaTextFileCitationAnnotation : MessageDeltaTextAnnotation - { - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - internal MessageDeltaTextFileCitationAnnotation(int index) : base(index) - { - Type = "file_citation"; - } - - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The type of the text content annotation. - /// Keeps track of any properties unknown to the library. - /// The file citation information. - /// The text in the message content that needs to be replaced. - /// The start index of this annotation in the content text. - /// The end index of this annotation in the content text. - internal MessageDeltaTextFileCitationAnnotation(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextFileCitationAnnotationObject fileCitation, string text, int? startIndex, int? endIndex) : base(index, type, serializedAdditionalRawData) - { - FileCitation = fileCitation; - Text = text; - StartIndex = startIndex; - EndIndex = endIndex; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaTextFileCitationAnnotation() - { - } - - /// The file citation information. - public MessageDeltaTextFileCitationAnnotationObject FileCitation { get; } - /// The text in the message content that needs to be replaced. - public string Text { get; } - /// The start index of this annotation in the content text. - public int? StartIndex { get; } - /// The end index of this annotation in the content text. - public int? EndIndex { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs deleted file mode 100644 index ea535eec934f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs +++ /dev/null @@ -1,156 +0,0 @@ -// 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 MessageDeltaTextFileCitationAnnotationObject : 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(MessageDeltaTextFileCitationAnnotationObject)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (Optional.IsDefined(Quote)) - { - writer.WritePropertyName("quote"u8); - writer.WriteStringValue(Quote); - } - 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 - } - } - } - - MessageDeltaTextFileCitationAnnotationObject 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(MessageDeltaTextFileCitationAnnotationObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextFileCitationAnnotationObject(document.RootElement, options); - } - - internal static MessageDeltaTextFileCitationAnnotationObject DeserializeMessageDeltaTextFileCitationAnnotationObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - string quote = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("quote"u8)) - { - quote = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageDeltaTextFileCitationAnnotationObject(fileId, quote, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextFileCitationAnnotationObject 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 DeserializeMessageDeltaTextFileCitationAnnotationObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} 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 MessageDeltaTextFileCitationAnnotationObject FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextFileCitationAnnotationObject(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/MessageDeltaTextFileCitationAnnotationObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs deleted file mode 100644 index ef326afe631b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents the data of a streamed file citation as applied to a streaming text content part. - public partial class MessageDeltaTextFileCitationAnnotationObject - { - /// - /// 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 . - internal MessageDeltaTextFileCitationAnnotationObject() - { - } - - /// Initializes a new instance of . - /// The ID of the specific file the citation is from. - /// The specific quote in the cited file. - /// Keeps track of any properties unknown to the library. - internal MessageDeltaTextFileCitationAnnotationObject(string fileId, string quote, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Quote = quote; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The ID of the specific file the citation is from. - public string FileId { get; } - /// The specific quote in the cited file. - public string Quote { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs deleted file mode 100644 index 4508bad7e0ce..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs +++ /dev/null @@ -1,195 +0,0 @@ -// 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 MessageDeltaTextFilePathAnnotation : 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(MessageDeltaTextFilePathAnnotation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(FilePath)) - { - writer.WritePropertyName("file_path"u8); - writer.WriteObjectValue(FilePath, options); - } - if (Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - if (Optional.IsDefined(Text)) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - } - - MessageDeltaTextFilePathAnnotation 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(MessageDeltaTextFilePathAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextFilePathAnnotation(document.RootElement, options); - } - - internal static MessageDeltaTextFilePathAnnotation DeserializeMessageDeltaTextFilePathAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageDeltaTextFilePathAnnotationObject filePath = default; - int? startIndex = default; - int? endIndex = default; - string text = default; - int index = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_path"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - filePath = MessageDeltaTextFilePathAnnotationObject.DeserializeMessageDeltaTextFilePathAnnotationObject(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 MessageDeltaTextFilePathAnnotation( - index, - type, - serializedAdditionalRawData, - filePath, - startIndex, - endIndex, - text); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextFilePathAnnotation 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 DeserializeMessageDeltaTextFilePathAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} 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 MessageDeltaTextFilePathAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextFilePathAnnotation(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/MessageDeltaTextFilePathAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotation.cs deleted file mode 100644 index 90bf54d5059b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotation.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a streamed file path annotation applied to a streaming text content part. - public partial class MessageDeltaTextFilePathAnnotation : MessageDeltaTextAnnotation - { - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - internal MessageDeltaTextFilePathAnnotation(int index) : base(index) - { - Type = "file_path"; - } - - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The type of the text content annotation. - /// Keeps track of any properties unknown to the library. - /// The file path information. - /// The start index of this annotation in the content text. - /// The end index of this annotation in the content text. - /// The text in the message content that needs to be replaced. - internal MessageDeltaTextFilePathAnnotation(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextFilePathAnnotationObject filePath, int? startIndex, int? endIndex, string text) : base(index, type, serializedAdditionalRawData) - { - FilePath = filePath; - StartIndex = startIndex; - EndIndex = endIndex; - Text = text; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaTextFilePathAnnotation() - { - } - - /// The file path information. - public MessageDeltaTextFilePathAnnotationObject FilePath { get; } - /// The start index of this annotation in the content text. - public int? StartIndex { get; } - /// The end index of this annotation in the content text. - public int? EndIndex { get; } - /// The text in the message content that needs to be replaced. - public string Text { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs deleted file mode 100644 index 1f556c48c323..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs +++ /dev/null @@ -1,145 +0,0 @@ -// 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 MessageDeltaTextFilePathAnnotationObject : 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(MessageDeltaTextFilePathAnnotationObject)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - 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 - } - } - } - - MessageDeltaTextFilePathAnnotationObject 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(MessageDeltaTextFilePathAnnotationObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextFilePathAnnotationObject(document.RootElement, options); - } - - internal static MessageDeltaTextFilePathAnnotationObject DeserializeMessageDeltaTextFilePathAnnotationObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageDeltaTextFilePathAnnotationObject(fileId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextFilePathAnnotationObject 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 DeserializeMessageDeltaTextFilePathAnnotationObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} 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 MessageDeltaTextFilePathAnnotationObject FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextFilePathAnnotationObject(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/MessageDeltaTextFilePathAnnotationObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs deleted file mode 100644 index 0bc0e8a00517..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents the data of a streamed file path annotation as applied to a streaming text content part. - public partial class MessageDeltaTextFilePathAnnotationObject - { - /// - /// 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 . - internal MessageDeltaTextFilePathAnnotationObject() - { - } - - /// Initializes a new instance of . - /// The file ID for the annotation. - /// Keeps track of any properties unknown to the library. - internal MessageDeltaTextFilePathAnnotationObject(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The file ID for the annotation. - public string FileId { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationAnnotation.Serialization.cs deleted file mode 100644 index ffebf235d348..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationAnnotation.Serialization.cs +++ /dev/null @@ -1,176 +0,0 @@ -// 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 MessageDeltaTextUrlCitationAnnotation : 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(MessageDeltaTextUrlCitationAnnotation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("url_citation"u8); - writer.WriteObjectValue(UrlCitation, options); - if (Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - } - - MessageDeltaTextUrlCitationAnnotation 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(MessageDeltaTextUrlCitationAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextUrlCitationAnnotation(document.RootElement, options); - } - - internal static MessageDeltaTextUrlCitationAnnotation DeserializeMessageDeltaTextUrlCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageDeltaTextUrlCitationDetails urlCitation = default; - int? startIndex = default; - int? endIndex = default; - int index = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("url_citation"u8)) - { - urlCitation = MessageDeltaTextUrlCitationDetails.DeserializeMessageDeltaTextUrlCitationDetails(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 MessageDeltaTextUrlCitationAnnotation( - index, - type, - serializedAdditionalRawData, - urlCitation, - startIndex, - endIndex); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextUrlCitationAnnotation 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 DeserializeMessageDeltaTextUrlCitationAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationAnnotation)} 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 MessageDeltaTextUrlCitationAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextUrlCitationAnnotation(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/MessageDeltaTextUrlCitationAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationAnnotation.cs deleted file mode 100644 index 6901df6957b2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationAnnotation.cs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 citation within the message that points to a specific URL associated with the message. Generated when the agent uses tools such as 'bing_grounding' to search the Internet. - public partial class MessageDeltaTextUrlCitationAnnotation : MessageDeltaTextAnnotation - { - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The details of the URL citation. - /// is null. - internal MessageDeltaTextUrlCitationAnnotation(int index, MessageDeltaTextUrlCitationDetails urlCitation) : base(index) - { - Argument.AssertNotNull(urlCitation, nameof(urlCitation)); - - Type = "url_citation"; - UrlCitation = urlCitation; - } - - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The type of the text content annotation. - /// Keeps track of any properties unknown to the library. - /// The details of the URL citation. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. - internal MessageDeltaTextUrlCitationAnnotation(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextUrlCitationDetails urlCitation, int? startIndex, int? endIndex) : base(index, type, serializedAdditionalRawData) - { - UrlCitation = urlCitation; - StartIndex = startIndex; - EndIndex = endIndex; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaTextUrlCitationAnnotation() - { - } - - /// The details of the URL citation. - public MessageDeltaTextUrlCitationDetails UrlCitation { get; } - /// The first text index associated with this text annotation. - public int? StartIndex { get; } - /// The last text index associated with this text annotation. - public int? EndIndex { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationDetails.Serialization.cs deleted file mode 100644 index 0ecf60293a41..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationDetails.Serialization.cs +++ /dev/null @@ -1,153 +0,0 @@ -// 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 MessageDeltaTextUrlCitationDetails : 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(MessageDeltaTextUrlCitationDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url); - if (Optional.IsDefined(Title)) - { - writer.WritePropertyName("title"u8); - writer.WriteStringValue(Title); - } - 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 - } - } - } - - MessageDeltaTextUrlCitationDetails 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(MessageDeltaTextUrlCitationDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextUrlCitationDetails(document.RootElement, options); - } - - internal static MessageDeltaTextUrlCitationDetails DeserializeMessageDeltaTextUrlCitationDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string url = default; - string title = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("url"u8)) - { - url = property.Value.GetString(); - continue; - } - if (property.NameEquals("title"u8)) - { - title = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageDeltaTextUrlCitationDetails(url, title, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationDetails)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextUrlCitationDetails 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 DeserializeMessageDeltaTextUrlCitationDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationDetails)} 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 MessageDeltaTextUrlCitationDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageDeltaTextUrlCitationDetails(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/MessageDeltaTextUrlCitationDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationDetails.cs deleted file mode 100644 index 26223d2ee019..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageDeltaTextUrlCitationDetails.cs +++ /dev/null @@ -1,79 +0,0 @@ -// 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 representation of a URL citation, as used in text thread message content. - public partial class MessageDeltaTextUrlCitationDetails - { - /// - /// 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 URL associated with this citation. - /// is null. - internal MessageDeltaTextUrlCitationDetails(string url) - { - Argument.AssertNotNull(url, nameof(url)); - - Url = url; - } - - /// Initializes a new instance of . - /// The URL associated with this citation. - /// The title of the URL. - /// Keeps track of any properties unknown to the library. - internal MessageDeltaTextUrlCitationDetails(string url, string title, IDictionary serializedAdditionalRawData) - { - Url = url; - Title = title; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageDeltaTextUrlCitationDetails() - { - } - - /// The URL associated with this citation. - public string Url { get; } - /// The title of the URL. - public string Title { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileContent.Serialization.cs deleted file mode 100644 index d3d3e82b7990..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileContent.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 MessageImageFileContent : 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(MessageImageFileContent)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("image_file"u8); - writer.WriteObjectValue(InternalDetails, options); - } - - MessageImageFileContent 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(MessageImageFileContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageImageFileContent(document.RootElement, options); - } - - internal static MessageImageFileContent DeserializeMessageImageFileContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalMessageImageFileDetails imageFile = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("image_file"u8)) - { - imageFile = InternalMessageImageFileDetails.DeserializeInternalMessageImageFileDetails(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 MessageImageFileContent(type, serializedAdditionalRawData, imageFile); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageImageFileContent)} does not support writing '{options.Format}' format."); - } - } - - MessageImageFileContent 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 DeserializeMessageImageFileContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageImageFileContent)} 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 MessageImageFileContent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageImageFileContent(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/MessageImageFileContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileContent.cs deleted file mode 100644 index 02acadb61ba2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileContent.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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 representation of image file content in a thread message. - public partial class MessageImageFileContent : MessageContent - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The image file for this thread message content item. - internal MessageImageFileContent(string type, IDictionary serializedAdditionalRawData, InternalMessageImageFileDetails internalDetails) : base(type, serializedAdditionalRawData) - { - InternalDetails = internalDetails; - } - - /// Initializes a new instance of for deserialization. - internal MessageImageFileContent() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.Serialization.cs deleted file mode 100644 index 64b54d66f018..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.Serialization.cs +++ /dev/null @@ -1,157 +0,0 @@ -// 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 MessageImageFileParam : 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(MessageImageFileParam)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - if (Optional.IsDefined(Detail)) - { - writer.WritePropertyName("detail"u8); - writer.WriteStringValue(Detail.Value.ToString()); - } - 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 - } - } - } - - MessageImageFileParam 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(MessageImageFileParam)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageImageFileParam(document.RootElement, options); - } - - internal static MessageImageFileParam DeserializeMessageImageFileParam(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - ImageDetailLevel? detail = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("detail"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - detail = new ImageDetailLevel(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageImageFileParam(fileId, detail, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageImageFileParam)} does not support writing '{options.Format}' format."); - } - } - - MessageImageFileParam 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 DeserializeMessageImageFileParam(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageImageFileParam)} 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 MessageImageFileParam FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageImageFileParam(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/MessageImageFileParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.cs deleted file mode 100644 index 7d8ac41222aa..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Defines how an internally uploaded image file is referenced when creating an image-file block. - public partial class MessageImageFileParam - { - /// - /// 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 ID of the previously uploaded image file. - /// is null. - public MessageImageFileParam(string fileId) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - } - - /// Initializes a new instance of . - /// The ID of the previously uploaded image file. - /// Optional detail level for the image (auto, low, or high). - /// Keeps track of any properties unknown to the library. - internal MessageImageFileParam(string fileId, ImageDetailLevel? detail, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Detail = detail; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageImageFileParam() - { - } - - /// The ID of the previously uploaded image file. - public string FileId { get; } - /// Optional detail level for the image (auto, low, or high). - public ImageDetailLevel? Detail { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.Serialization.cs deleted file mode 100644 index da595d4f3f83..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.Serialization.cs +++ /dev/null @@ -1,157 +0,0 @@ -// 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 MessageImageUrlParam : 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(MessageImageUrlParam)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url); - if (Optional.IsDefined(Detail)) - { - writer.WritePropertyName("detail"u8); - writer.WriteStringValue(Detail.Value.ToString()); - } - 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 - } - } - } - - MessageImageUrlParam 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(MessageImageUrlParam)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageImageUrlParam(document.RootElement, options); - } - - internal static MessageImageUrlParam DeserializeMessageImageUrlParam(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string url = default; - ImageDetailLevel? detail = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("url"u8)) - { - url = property.Value.GetString(); - continue; - } - if (property.NameEquals("detail"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - detail = new ImageDetailLevel(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageImageUrlParam(url, detail, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageImageUrlParam)} does not support writing '{options.Format}' format."); - } - } - - MessageImageUrlParam 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 DeserializeMessageImageUrlParam(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageImageUrlParam)} 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 MessageImageUrlParam FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageImageUrlParam(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/MessageImageUrlParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.cs deleted file mode 100644 index 5bdb1cda03f9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Defines how an external image URL is referenced when creating an image-URL block. - public partial class MessageImageUrlParam - { - /// - /// 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 publicly accessible URL of the external image. - /// is null. - public MessageImageUrlParam(string url) - { - Argument.AssertNotNull(url, nameof(url)); - - Url = url; - } - - /// Initializes a new instance of . - /// The publicly accessible URL of the external image. - /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. - /// Keeps track of any properties unknown to the library. - internal MessageImageUrlParam(string url, ImageDetailLevel? detail, IDictionary serializedAdditionalRawData) - { - Url = url; - Detail = detail; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageImageUrlParam() - { - } - - /// The publicly accessible URL of the external image. - public string Url { get; } - /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. - public ImageDetailLevel? Detail { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageIncompleteDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageIncompleteDetails.Serialization.cs deleted file mode 100644 index 0a98936f9c18..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageIncompleteDetails.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 MessageIncompleteDetails : 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(MessageIncompleteDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("reason"u8); - writer.WriteStringValue(Reason.ToString()); - 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 - } - } - } - - MessageIncompleteDetails 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(MessageIncompleteDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageIncompleteDetails(document.RootElement, options); - } - - internal static MessageIncompleteDetails DeserializeMessageIncompleteDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageIncompleteDetailsReason reason = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("reason"u8)) - { - reason = new MessageIncompleteDetailsReason(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageIncompleteDetails(reason, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support writing '{options.Format}' format."); - } - } - - MessageIncompleteDetails 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 DeserializeMessageIncompleteDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageIncompleteDetails)} 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 MessageIncompleteDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageIncompleteDetails(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/MessageIncompleteDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageIncompleteDetails.cs deleted file mode 100644 index 5688889deda3..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageIncompleteDetails.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Information providing additional detail about a message entering an incomplete status. - public partial class MessageIncompleteDetails - { - /// - /// 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 provided reason describing why the message was marked as incomplete. - internal MessageIncompleteDetails(MessageIncompleteDetailsReason reason) - { - Reason = reason; - } - - /// Initializes a new instance of . - /// The provided reason describing why the message was marked as incomplete. - /// Keeps track of any properties unknown to the library. - internal MessageIncompleteDetails(MessageIncompleteDetailsReason reason, IDictionary serializedAdditionalRawData) - { - Reason = reason; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageIncompleteDetails() - { - } - - /// The provided reason describing why the message was marked as incomplete. - public MessageIncompleteDetailsReason Reason { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageIncompleteDetailsReason.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageIncompleteDetailsReason.cs deleted file mode 100644 index 46c6f650afab..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageIncompleteDetailsReason.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// A set of reasons describing why a message is marked as incomplete. - public readonly partial struct MessageIncompleteDetailsReason : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public MessageIncompleteDetailsReason(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ContentFilterValue = "content_filter"; - private const string MaxTokensValue = "max_tokens"; - private const string RunCancelledValue = "run_cancelled"; - private const string RunFailedValue = "run_failed"; - private const string RunExpiredValue = "run_expired"; - - /// The run generating the message was terminated due to content filter flagging. - public static MessageIncompleteDetailsReason ContentFilter { get; } = new MessageIncompleteDetailsReason(ContentFilterValue); - /// The run generating the message exhausted available tokens before completion. - public static MessageIncompleteDetailsReason MaxTokens { get; } = new MessageIncompleteDetailsReason(MaxTokensValue); - /// The run generating the message was cancelled before completion. - public static MessageIncompleteDetailsReason RunCancelled { get; } = new MessageIncompleteDetailsReason(RunCancelledValue); - /// The run generating the message failed. - public static MessageIncompleteDetailsReason RunFailed { get; } = new MessageIncompleteDetailsReason(RunFailedValue); - /// The run generating the message expired. - public static MessageIncompleteDetailsReason RunExpired { get; } = new MessageIncompleteDetailsReason(RunExpiredValue); - /// Determines if two values are the same. - public static bool operator ==(MessageIncompleteDetailsReason left, MessageIncompleteDetailsReason right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(MessageIncompleteDetailsReason left, MessageIncompleteDetailsReason right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator MessageIncompleteDetailsReason(string value) => new MessageIncompleteDetailsReason(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageIncompleteDetailsReason other && Equals(other); - /// - public bool Equals(MessageIncompleteDetailsReason 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/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.cs deleted file mode 100644 index 833cdad0dbcf..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// Defines a single content block when creating a message. The 'type' field determines whether it is text, an image file, or an external image URL, etc. - /// 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 MessageInputContentBlock - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected MessageInputContentBlock() - { - } - - /// Initializes a new instance of . - /// Specifies which kind of content block this is (text, image_file, image_url, etc.). - /// Keeps track of any properties unknown to the library. - internal MessageInputContentBlock(MessageBlockType type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Specifies which kind of content block this is (text, image_file, image_url, etc.). - internal MessageBlockType Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.Serialization.cs deleted file mode 100644 index 26cbf3ff5d31..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 MessageInputImageFileBlock : 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(MessageInputImageFileBlock)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("image_file"u8); - writer.WriteObjectValue(ImageFile, options); - } - - MessageInputImageFileBlock 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(MessageInputImageFileBlock)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageInputImageFileBlock(document.RootElement, options); - } - - internal static MessageInputImageFileBlock DeserializeMessageInputImageFileBlock(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageImageFileParam imageFile = default; - MessageBlockType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("image_file"u8)) - { - imageFile = MessageImageFileParam.DeserializeMessageImageFileParam(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new MessageBlockType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageInputImageFileBlock(type, serializedAdditionalRawData, imageFile); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageInputImageFileBlock)} does not support writing '{options.Format}' format."); - } - } - - MessageInputImageFileBlock 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 DeserializeMessageInputImageFileBlock(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageInputImageFileBlock)} 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 MessageInputImageFileBlock FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageInputImageFileBlock(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/MessageInputImageFileBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.cs deleted file mode 100644 index fe86d8a41677..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// An image-file block in a new message, referencing an internally uploaded image by file ID. - public partial class MessageInputImageFileBlock : MessageInputContentBlock - { - /// Initializes a new instance of . - /// Information about the referenced image file, including file ID and optional detail level. - /// is null. - public MessageInputImageFileBlock(MessageImageFileParam imageFile) - { - Argument.AssertNotNull(imageFile, nameof(imageFile)); - - Type = MessageBlockType.ImageFile; - ImageFile = imageFile; - } - - /// Initializes a new instance of . - /// Specifies which kind of content block this is (text, image_file, image_url, etc.). - /// Keeps track of any properties unknown to the library. - /// Information about the referenced image file, including file ID and optional detail level. - internal MessageInputImageFileBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, MessageImageFileParam imageFile) : base(type, serializedAdditionalRawData) - { - ImageFile = imageFile; - } - - /// Initializes a new instance of for deserialization. - internal MessageInputImageFileBlock() - { - } - - /// Information about the referenced image file, including file ID and optional detail level. - public MessageImageFileParam ImageFile { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.Serialization.cs deleted file mode 100644 index c2f3dbd02e11..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 MessageInputImageUrlBlock : 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(MessageInputImageUrlBlock)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("image_url"u8); - writer.WriteObjectValue(ImageUrl, options); - } - - MessageInputImageUrlBlock 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(MessageInputImageUrlBlock)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageInputImageUrlBlock(document.RootElement, options); - } - - internal static MessageInputImageUrlBlock DeserializeMessageInputImageUrlBlock(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageImageUrlParam imageUrl = default; - MessageBlockType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("image_url"u8)) - { - imageUrl = MessageImageUrlParam.DeserializeMessageImageUrlParam(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new MessageBlockType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageInputImageUrlBlock(type, serializedAdditionalRawData, imageUrl); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageInputImageUrlBlock)} does not support writing '{options.Format}' format."); - } - } - - MessageInputImageUrlBlock 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 DeserializeMessageInputImageUrlBlock(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageInputImageUrlBlock)} 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 MessageInputImageUrlBlock FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageInputImageUrlBlock(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/MessageInputImageUrlBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.cs deleted file mode 100644 index 7bcaf487cecc..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// An image-URL block in a new message, referencing an external image by URL. - public partial class MessageInputImageUrlBlock : MessageInputContentBlock - { - /// Initializes a new instance of . - /// Information about the external image URL, including the URL and optional detail level. - /// is null. - public MessageInputImageUrlBlock(MessageImageUrlParam imageUrl) - { - Argument.AssertNotNull(imageUrl, nameof(imageUrl)); - - Type = MessageBlockType.ImageUrl; - ImageUrl = imageUrl; - } - - /// Initializes a new instance of . - /// Specifies which kind of content block this is (text, image_file, image_url, etc.). - /// Keeps track of any properties unknown to the library. - /// Information about the external image URL, including the URL and optional detail level. - internal MessageInputImageUrlBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, MessageImageUrlParam imageUrl) : base(type, serializedAdditionalRawData) - { - ImageUrl = imageUrl; - } - - /// Initializes a new instance of for deserialization. - internal MessageInputImageUrlBlock() - { - } - - /// Information about the external image URL, including the URL and optional detail level. - public MessageImageUrlParam ImageUrl { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.Serialization.cs deleted file mode 100644 index f9d2e5a7174b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 MessageInputTextBlock : 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(MessageInputTextBlock)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - - MessageInputTextBlock 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(MessageInputTextBlock)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageInputTextBlock(document.RootElement, options); - } - - internal static MessageInputTextBlock DeserializeMessageInputTextBlock(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string text = default; - MessageBlockType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new MessageBlockType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageInputTextBlock(type, serializedAdditionalRawData, text); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageInputTextBlock)} does not support writing '{options.Format}' format."); - } - } - - MessageInputTextBlock 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 DeserializeMessageInputTextBlock(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageInputTextBlock)} 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 MessageInputTextBlock FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageInputTextBlock(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/MessageInputTextBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.cs deleted file mode 100644 index 1e7846da5eb5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 text block in a new message, containing plain text content. - public partial class MessageInputTextBlock : MessageInputContentBlock - { - /// Initializes a new instance of . - /// The plain text content for this block. - /// is null. - public MessageInputTextBlock(string text) - { - Argument.AssertNotNull(text, nameof(text)); - - Type = MessageBlockType.Text; - Text = text; - } - - /// Initializes a new instance of . - /// Specifies which kind of content block this is (text, image_file, image_url, etc.). - /// Keeps track of any properties unknown to the library. - /// The plain text content for this block. - internal MessageInputTextBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, string text) : base(type, serializedAdditionalRawData) - { - Text = text; - } - - /// Initializes a new instance of for deserialization. - internal MessageInputTextBlock() - { - } - - /// The plain text content for this block. - public string Text { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageRole.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageRole.cs deleted file mode 100644 index e60b22c12089..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageRole.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The possible values for roles attributed to messages in a thread. - public readonly partial struct MessageRole : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public MessageRole(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string UserValue = "user"; - private const string AgentValue = "assistant"; - - /// The role representing the end-user. - public static MessageRole User { get; } = new MessageRole(UserValue); - /// The role representing the agent. - public static MessageRole Agent { get; } = new MessageRole(AgentValue); - /// Determines if two values are the same. - public static bool operator ==(MessageRole left, MessageRole right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(MessageRole left, MessageRole right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator MessageRole(string value) => new MessageRole(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageRole other && Equals(other); - /// - public bool Equals(MessageRole 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/sdk/ai/Azure.AI.Projects/src/Generated/MessageStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageStatus.cs deleted file mode 100644 index 79b8382bc0ef..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageStatus.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The possible execution status values for a thread message. - public readonly partial struct MessageStatus : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public MessageStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string IncompleteValue = "incomplete"; - private const string CompletedValue = "completed"; - - /// A run is currently creating this message. - public static MessageStatus InProgress { get; } = new MessageStatus(InProgressValue); - /// This message is incomplete. See incomplete_details for more information. - public static MessageStatus Incomplete { get; } = new MessageStatus(IncompleteValue); - /// This message was successfully completed by a run. - public static MessageStatus Completed { get; } = new MessageStatus(CompletedValue); - /// Determines if two values are the same. - public static bool operator ==(MessageStatus left, MessageStatus right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(MessageStatus left, MessageStatus right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator MessageStatus(string value) => new MessageStatus(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageStatus other && Equals(other); - /// - public bool Equals(MessageStatus 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/sdk/ai/Azure.AI.Projects/src/Generated/MessageStreamEvent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageStreamEvent.cs deleted file mode 100644 index 333c12b43a3f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageStreamEvent.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Message operation related streaming events. - public readonly partial struct MessageStreamEvent : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public MessageStreamEvent(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ThreadMessageCreatedValue = "thread.message.created"; - private const string ThreadMessageInProgressValue = "thread.message.in_progress"; - private const string ThreadMessageDeltaValue = "thread.message.delta"; - private const string ThreadMessageCompletedValue = "thread.message.completed"; - private const string ThreadMessageIncompleteValue = "thread.message.incomplete"; - - /// Event sent when a new message is created. The data of this event is of type ThreadMessage. - public static MessageStreamEvent ThreadMessageCreated { get; } = new MessageStreamEvent(ThreadMessageCreatedValue); - /// Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage. - public static MessageStreamEvent ThreadMessageInProgress { get; } = new MessageStreamEvent(ThreadMessageInProgressValue); - /// Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk. - public static MessageStreamEvent ThreadMessageDelta { get; } = new MessageStreamEvent(ThreadMessageDeltaValue); - /// Event sent when a message is completed. The data of this event is of type ThreadMessage. - public static MessageStreamEvent ThreadMessageCompleted { get; } = new MessageStreamEvent(ThreadMessageCompletedValue); - /// Event sent before a message is completed. The data of this event is of type ThreadMessage. - public static MessageStreamEvent ThreadMessageIncomplete { get; } = new MessageStreamEvent(ThreadMessageIncompleteValue); - /// Determines if two values are the same. - public static bool operator ==(MessageStreamEvent left, MessageStreamEvent right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(MessageStreamEvent left, MessageStreamEvent right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator MessageStreamEvent(string value) => new MessageStreamEvent(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageStreamEvent other && Equals(other); - /// - public bool Equals(MessageStreamEvent 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/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextAnnotation.Serialization.cs deleted file mode 100644 index 24918365780e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextAnnotation.Serialization.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownMessageTextAnnotation))] - public partial class MessageTextAnnotation : 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(MessageTextAnnotation)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - 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 - } - } - } - - MessageTextAnnotation 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(MessageTextAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageTextAnnotation(document.RootElement, options); - } - - internal static MessageTextAnnotation DeserializeMessageTextAnnotation(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 "file_citation": return MessageTextFileCitationAnnotation.DeserializeMessageTextFileCitationAnnotation(element, options); - case "file_path": return MessageTextFilePathAnnotation.DeserializeMessageTextFilePathAnnotation(element, options); - case "url_citation": return MessageTextUrlCitationAnnotation.DeserializeMessageTextUrlCitationAnnotation(element, options); - } - } - return UnknownMessageTextAnnotation.DeserializeUnknownMessageTextAnnotation(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageTextAnnotation 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 DeserializeMessageTextAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageTextAnnotation)} 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 MessageTextAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageTextAnnotation(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/MessageTextAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextAnnotation.cs deleted file mode 100644 index 833119a2a8ec..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextAnnotation.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// An abstract representation of an annotation to text thread message content. - /// 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 MessageTextAnnotation - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The textual content associated with this text annotation item. - /// is null. - protected MessageTextAnnotation(string text) - { - Argument.AssertNotNull(text, nameof(text)); - - Text = text; - } - - /// Initializes a new instance of . - /// The object type. - /// The textual content associated with this text annotation item. - /// Keeps track of any properties unknown to the library. - internal MessageTextAnnotation(string type, string text, IDictionary serializedAdditionalRawData) - { - Type = type; - Text = text; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageTextAnnotation() - { - } - - /// The object type. - internal string Type { get; set; } - /// The textual content associated with this text annotation item. - public string Text { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextContent.Serialization.cs deleted file mode 100644 index 04834c424bca..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextContent.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 MessageTextContent : 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(MessageTextContent)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("text"u8); - writer.WriteObjectValue(InternalDetails, options); - } - - MessageTextContent 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(MessageTextContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageTextContent(document.RootElement, options); - } - - internal static MessageTextContent DeserializeMessageTextContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalMessageTextDetails text = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("text"u8)) - { - text = InternalMessageTextDetails.DeserializeInternalMessageTextDetails(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 MessageTextContent(type, serializedAdditionalRawData, text); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageTextContent)} does not support writing '{options.Format}' format."); - } - } - - MessageTextContent 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 DeserializeMessageTextContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageTextContent)} 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 MessageTextContent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageTextContent(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/MessageTextContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextContent.cs deleted file mode 100644 index bfc181bb0a23..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextContent.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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 representation of a textual item of thread message content. - public partial class MessageTextContent : MessageContent - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The text and associated annotations for this thread message content item. - internal MessageTextContent(string type, IDictionary serializedAdditionalRawData, InternalMessageTextDetails internalDetails) : base(type, serializedAdditionalRawData) - { - InternalDetails = internalDetails; - } - - /// Initializes a new instance of for deserialization. - internal MessageTextContent() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs deleted file mode 100644 index 63c715ceee47..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs +++ /dev/null @@ -1,176 +0,0 @@ -// 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 MessageTextFileCitationAnnotation : 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(MessageTextFileCitationAnnotation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("file_citation"u8); - writer.WriteObjectValue(InternalDetails, options); - if (Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - } - - MessageTextFileCitationAnnotation 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(MessageTextFileCitationAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageTextFileCitationAnnotation(document.RootElement, options); - } - - internal static MessageTextFileCitationAnnotation DeserializeMessageTextFileCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalMessageTextFileCitationDetails fileCitation = default; - int? startIndex = default; - int? endIndex = default; - string type = default; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_citation"u8)) - { - fileCitation = InternalMessageTextFileCitationDetails.DeserializeInternalMessageTextFileCitationDetails(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageTextFileCitationAnnotation( - type, - text, - serializedAdditionalRawData, - fileCitation, - startIndex, - endIndex); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageTextFileCitationAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageTextFileCitationAnnotation 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 DeserializeMessageTextFileCitationAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageTextFileCitationAnnotation)} 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 MessageTextFileCitationAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageTextFileCitationAnnotation(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/MessageTextFileCitationAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFileCitationAnnotation.cs deleted file mode 100644 index f1295b6fa3d9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFileCitationAnnotation.cs +++ /dev/null @@ -1,42 +0,0 @@ -// 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 citation within the message that points to a specific quote from a specific File associated with the agent or the message. Generated when the agent uses the 'file_search' tool to search files. - public partial class MessageTextFileCitationAnnotation : MessageTextAnnotation - { - /// Initializes a new instance of . - /// The object type. - /// The textual content associated with this text annotation item. - /// Keeps track of any properties unknown to the library. - /// - /// A citation within the message that points to a specific quote from a specific file. - /// Generated when the agent uses the "file_search" tool to search files. - /// - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. - internal MessageTextFileCitationAnnotation(string type, string text, IDictionary serializedAdditionalRawData, InternalMessageTextFileCitationDetails internalDetails, int? startIndex, int? endIndex) : base(type, text, serializedAdditionalRawData) - { - InternalDetails = internalDetails; - StartIndex = startIndex; - EndIndex = endIndex; - } - - /// Initializes a new instance of for deserialization. - internal MessageTextFileCitationAnnotation() - { - } - /// The first text index associated with this text annotation. - public int? StartIndex { get; } - /// The last text index associated with this text annotation. - public int? EndIndex { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFilePathAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFilePathAnnotation.Serialization.cs deleted file mode 100644 index fa8c84e7d44b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFilePathAnnotation.Serialization.cs +++ /dev/null @@ -1,176 +0,0 @@ -// 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 MessageTextFilePathAnnotation : 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(MessageTextFilePathAnnotation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("file_path"u8); - writer.WriteObjectValue(InternalDetails, options); - if (Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - } - - MessageTextFilePathAnnotation 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(MessageTextFilePathAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageTextFilePathAnnotation(document.RootElement, options); - } - - internal static MessageTextFilePathAnnotation DeserializeMessageTextFilePathAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalMessageTextFilePathDetails filePath = default; - int? startIndex = default; - int? endIndex = default; - string type = default; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_path"u8)) - { - filePath = InternalMessageTextFilePathDetails.DeserializeInternalMessageTextFilePathDetails(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageTextFilePathAnnotation( - type, - text, - serializedAdditionalRawData, - filePath, - startIndex, - endIndex); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageTextFilePathAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageTextFilePathAnnotation 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 DeserializeMessageTextFilePathAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageTextFilePathAnnotation)} 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 MessageTextFilePathAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageTextFilePathAnnotation(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/MessageTextFilePathAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFilePathAnnotation.cs deleted file mode 100644 index ccf74d5173f4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextFilePathAnnotation.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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 citation within the message that points to a file located at a specific path. - public partial class MessageTextFilePathAnnotation : MessageTextAnnotation - { - /// Initializes a new instance of . - /// The object type. - /// The textual content associated with this text annotation item. - /// Keeps track of any properties unknown to the library. - /// A URL for the file that's generated when the agent used the code_interpreter tool to generate a file. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. - internal MessageTextFilePathAnnotation(string type, string text, IDictionary serializedAdditionalRawData, InternalMessageTextFilePathDetails internalDetails, int? startIndex, int? endIndex) : base(type, text, serializedAdditionalRawData) - { - InternalDetails = internalDetails; - StartIndex = startIndex; - EndIndex = endIndex; - } - - /// Initializes a new instance of for deserialization. - internal MessageTextFilePathAnnotation() - { - } - /// The first text index associated with this text annotation. - public int? StartIndex { get; } - /// The last text index associated with this text annotation. - public int? EndIndex { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationAnnotation.Serialization.cs deleted file mode 100644 index b8d785ed3cb9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationAnnotation.Serialization.cs +++ /dev/null @@ -1,176 +0,0 @@ -// 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 MessageTextUrlCitationAnnotation : 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(MessageTextUrlCitationAnnotation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("url_citation"u8); - writer.WriteObjectValue(UrlCitation, options); - if (Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - } - - MessageTextUrlCitationAnnotation 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(MessageTextUrlCitationAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageTextUrlCitationAnnotation(document.RootElement, options); - } - - internal static MessageTextUrlCitationAnnotation DeserializeMessageTextUrlCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageTextUrlCitationDetails urlCitation = default; - int? startIndex = default; - int? endIndex = default; - string type = default; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("url_citation"u8)) - { - urlCitation = MessageTextUrlCitationDetails.DeserializeMessageTextUrlCitationDetails(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageTextUrlCitationAnnotation( - type, - text, - serializedAdditionalRawData, - urlCitation, - startIndex, - endIndex); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageTextUrlCitationAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageTextUrlCitationAnnotation 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 DeserializeMessageTextUrlCitationAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageTextUrlCitationAnnotation)} 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 MessageTextUrlCitationAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageTextUrlCitationAnnotation(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/MessageTextUrlCitationAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationAnnotation.cs deleted file mode 100644 index 7ffa68e389a4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationAnnotation.cs +++ /dev/null @@ -1,55 +0,0 @@ -// 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 citation within the message that points to a specific URL associated with the message. Generated when the agent uses tools such as 'bing_grounding' to search the Internet. - public partial class MessageTextUrlCitationAnnotation : MessageTextAnnotation - { - /// Initializes a new instance of . - /// The textual content associated with this text annotation item. - /// The details of the URL citation. - /// or is null. - internal MessageTextUrlCitationAnnotation(string text, MessageTextUrlCitationDetails urlCitation) : base(text) - { - Argument.AssertNotNull(text, nameof(text)); - Argument.AssertNotNull(urlCitation, nameof(urlCitation)); - - Type = "url_citation"; - UrlCitation = urlCitation; - } - - /// Initializes a new instance of . - /// The object type. - /// The textual content associated with this text annotation item. - /// Keeps track of any properties unknown to the library. - /// The details of the URL citation. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. - internal MessageTextUrlCitationAnnotation(string type, string text, IDictionary serializedAdditionalRawData, MessageTextUrlCitationDetails urlCitation, int? startIndex, int? endIndex) : base(type, text, serializedAdditionalRawData) - { - UrlCitation = urlCitation; - StartIndex = startIndex; - EndIndex = endIndex; - } - - /// Initializes a new instance of for deserialization. - internal MessageTextUrlCitationAnnotation() - { - } - - /// The details of the URL citation. - public MessageTextUrlCitationDetails UrlCitation { get; } - /// The first text index associated with this text annotation. - public int? StartIndex { get; } - /// The last text index associated with this text annotation. - public int? EndIndex { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationDetails.Serialization.cs deleted file mode 100644 index 11e9be98e53d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationDetails.Serialization.cs +++ /dev/null @@ -1,153 +0,0 @@ -// 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 MessageTextUrlCitationDetails : 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(MessageTextUrlCitationDetails)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url); - if (Optional.IsDefined(Title)) - { - writer.WritePropertyName("title"u8); - writer.WriteStringValue(Title); - } - 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 - } - } - } - - MessageTextUrlCitationDetails 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(MessageTextUrlCitationDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageTextUrlCitationDetails(document.RootElement, options); - } - - internal static MessageTextUrlCitationDetails DeserializeMessageTextUrlCitationDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string url = default; - string title = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("url"u8)) - { - url = property.Value.GetString(); - continue; - } - if (property.NameEquals("title"u8)) - { - title = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MessageTextUrlCitationDetails(url, title, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageTextUrlCitationDetails)} does not support writing '{options.Format}' format."); - } - } - - MessageTextUrlCitationDetails 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 DeserializeMessageTextUrlCitationDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageTextUrlCitationDetails)} 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 MessageTextUrlCitationDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageTextUrlCitationDetails(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/MessageTextUrlCitationDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationDetails.cs deleted file mode 100644 index b39dd77505c7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MessageTextUrlCitationDetails.cs +++ /dev/null @@ -1,79 +0,0 @@ -// 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 representation of a URL citation, as used in text thread message content. - public partial class MessageTextUrlCitationDetails - { - /// - /// 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 URL associated with this citation. - /// is null. - internal MessageTextUrlCitationDetails(string url) - { - Argument.AssertNotNull(url, nameof(url)); - - Url = url; - } - - /// Initializes a new instance of . - /// The URL associated with this citation. - /// The title of the URL. - /// Keeps track of any properties unknown to the library. - internal MessageTextUrlCitationDetails(string url, string title, IDictionary serializedAdditionalRawData) - { - Url = url; - Title = title; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MessageTextUrlCitationDetails() - { - } - - /// The URL associated with this citation. - public string Url { get; } - /// The title of the URL. - public string Title { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricToolDefinition.cs deleted file mode 100644 index abed6492094f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricToolDefinition.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 Microsoft Fabric tool as used to configure an agent. - public partial class MicrosoftFabricToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - /// The list of connections used by the Microsoft Fabric tool. - /// is null. - public MicrosoftFabricToolDefinition(ToolConnectionList fabricDataagent) - { - Argument.AssertNotNull(fabricDataagent, nameof(fabricDataagent)); - - Type = "fabric_dataagent"; - FabricDataagent = fabricDataagent; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The list of connections used by the Microsoft Fabric tool. - internal MicrosoftFabricToolDefinition(string type, IDictionary serializedAdditionalRawData, ToolConnectionList fabricDataagent) : base(type, serializedAdditionalRawData) - { - FabricDataagent = fabricDataagent; - } - - /// Initializes a new instance of for deserialization. - internal MicrosoftFabricToolDefinition() - { - } - - /// The list of connections used by the Microsoft Fabric tool. - public ToolConnectionList FabricDataagent { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ModelDeployment.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ModelDeployment.Serialization.cs new file mode 100644 index 000000000000..d63ac9b72f37 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ModelDeployment.Serialization.cs @@ -0,0 +1,218 @@ +// 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 ModelDeployment : 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(ModelDeployment)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (options.Format != "W") + { + writer.WritePropertyName("modelName"u8); + writer.WriteStringValue(ModelName); + } + if (options.Format != "W") + { + writer.WritePropertyName("modelVersion"u8); + writer.WriteStringValue(ModelVersion); + } + if (options.Format != "W") + { + writer.WritePropertyName("modelPublisher"u8); + writer.WriteStringValue(ModelPublisher); + } + if (options.Format != "W") + { + writer.WritePropertyName("capabilities"u8); + writer.WriteStartObject(); + foreach (var item in Capabilities) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W") + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + if (options.Format != "W" && Optional.IsDefined(ConnectionName)) + { + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + } + } + + ModelDeployment 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(ModelDeployment)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelDeployment(document.RootElement, options); + } + + internal static ModelDeployment DeserializeModelDeployment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string modelName = default; + string modelVersion = default; + string modelPublisher = default; + IReadOnlyDictionary capabilities = default; + Sku sku = default; + string connectionName = default; + DeploymentType type = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("modelName"u8)) + { + modelName = property.Value.GetString(); + continue; + } + if (property.NameEquals("modelVersion"u8)) + { + modelVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("modelPublisher"u8)) + { + modelPublisher = property.Value.GetString(); + continue; + } + if (property.NameEquals("capabilities"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + capabilities = dictionary; + continue; + } + if (property.NameEquals("sku"u8)) + { + sku = Sku.DeserializeSku(property.Value, options); + continue; + } + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new DeploymentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ModelDeployment( + type, + name, + serializedAdditionalRawData, + modelName, + modelVersion, + modelPublisher, + capabilities, + sku, + connectionName); + } + + 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, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ModelDeployment)} does not support writing '{options.Format}' format."); + } + } + + ModelDeployment 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 DeserializeModelDeployment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelDeployment)} 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 ModelDeployment FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeModelDeployment(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/ModelDeployment.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ModelDeployment.cs new file mode 100644 index 000000000000..4ba31da12dda --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ModelDeployment.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Model Deployment Definition. + public partial class ModelDeployment : Deployment + { + /// Initializes a new instance of . + internal ModelDeployment() + { + Type = DeploymentType.ModelDeployment; + Capabilities = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The type of the deployment. + /// Name of the deployment. + /// Keeps track of any properties unknown to the library. + /// Publisher-specific name of the deployed model. + /// Publisher-specific version of the deployed model. + /// Name of the deployed model's publisher. + /// Capabilities of deployed model. + /// Sku of the model deployment. + /// Name of the connection the deployment comes from. + internal ModelDeployment(DeploymentType type, string name, IDictionary serializedAdditionalRawData, string modelName, string modelVersion, string modelPublisher, IReadOnlyDictionary capabilities, Sku sku, string connectionName) : base(type, name, serializedAdditionalRawData) + { + ModelName = modelName; + ModelVersion = modelVersion; + ModelPublisher = modelPublisher; + Capabilities = capabilities; + Sku = sku; + ConnectionName = connectionName; + } + + /// Publisher-specific name of the deployed model. + public string ModelName { get; } + /// Publisher-specific version of the deployed model. + public string ModelVersion { get; } + /// Name of the deployed model's publisher. + public string ModelPublisher { get; } + /// Capabilities of deployed model. + public IReadOnlyDictionary Capabilities { get; } + /// Sku of the model deployment. + public Sku Sku { get; } + /// Name of the connection the deployment comes from. + public string ConnectionName { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ModifyVectorStoreRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ModifyVectorStoreRequest.Serialization.cs deleted file mode 100644 index 77c6b8954451..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ModifyVectorStoreRequest.Serialization.cs +++ /dev/null @@ -1,213 +0,0 @@ -// 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 -{ - internal partial class ModifyVectorStoreRequest : 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(ModifyVectorStoreRequest)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(Name)) - { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } - } - if (Optional.IsDefined(ExpiresAfter)) - { - if (ExpiresAfter != null) - { - writer.WritePropertyName("expires_after"u8); - writer.WriteObjectValue(ExpiresAfter, options); - } - else - { - writer.WriteNull("expires_after"); - } - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - ModifyVectorStoreRequest 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(ModifyVectorStoreRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeModifyVectorStoreRequest(document.RootElement, options); - } - - internal static ModifyVectorStoreRequest DeserializeModifyVectorStoreRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - VectorStoreExpirationPolicy expiresAfter = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("name"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("expires_after"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - expiresAfter = null; - continue; - } - expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ModifyVectorStoreRequest(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ModifyVectorStoreRequest)} does not support writing '{options.Format}' format."); - } - } - - ModifyVectorStoreRequest 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 DeserializeModifyVectorStoreRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModifyVectorStoreRequest)} 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 ModifyVectorStoreRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeModifyVectorStoreRequest(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/ModifyVectorStoreRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ModifyVectorStoreRequest.cs deleted file mode 100644 index dc1d4cb9889d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ModifyVectorStoreRequest.cs +++ /dev/null @@ -1,74 +0,0 @@ -// 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 ModifyVectorStoreRequest. - internal partial class ModifyVectorStoreRequest - { - /// - /// 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 . - internal ModifyVectorStoreRequest() - { - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The name of the vector store. - /// Details on when this vector store expires. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal ModifyVectorStoreRequest(string name, VectorStoreExpirationPolicy expiresAfter, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Name = name; - ExpiresAfter = expiresAfter; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The name of the vector store. - public string Name { get; } - /// Details on when this vector store expires. - public VectorStoreExpirationPolicy ExpiresAfter { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/NoAuthenticationCredentials.Serialization.cs similarity index 68% rename from sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolDefinition.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/NoAuthenticationCredentials.Serialization.cs index 47073371ae56..8931615e18aa 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolDefinition.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/NoAuthenticationCredentials.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class AzureAISearchToolDefinition : IUtf8JsonSerializable, IJsonModel + public partial class NoAuthenticationCredentials : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,28 +28,28 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AzureAISearchToolDefinition)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(NoAuthenticationCredentials)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); } - AzureAISearchToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + NoAuthenticationCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AzureAISearchToolDefinition)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(NoAuthenticationCredentials)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAzureAISearchToolDefinition(document.RootElement, options); + return DeserializeNoAuthenticationCredentials(document.RootElement, options); } - internal static AzureAISearchToolDefinition DeserializeAzureAISearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + internal static NoAuthenticationCredentials DeserializeNoAuthenticationCredentials(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -57,14 +57,14 @@ internal static AzureAISearchToolDefinition DeserializeAzureAISearchToolDefiniti { return null; } - string type = default; + CredentialType type = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) { - type = property.Value.GetString(); + type = new CredentialType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -73,46 +73,46 @@ internal static AzureAISearchToolDefinition DeserializeAzureAISearchToolDefiniti } } serializedAdditionalRawData = rawDataDictionary; - return new AzureAISearchToolDefinition(type, serializedAdditionalRawData); + return new NoAuthenticationCredentials(type, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(AzureAISearchToolDefinition)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(NoAuthenticationCredentials)} does not support writing '{options.Format}' format."); } } - AzureAISearchToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + NoAuthenticationCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAzureAISearchToolDefinition(document.RootElement, options); + return DeserializeNoAuthenticationCredentials(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(AzureAISearchToolDefinition)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(NoAuthenticationCredentials)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new AzureAISearchToolDefinition FromResponse(Response response) + internal static new NoAuthenticationCredentials FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAzureAISearchToolDefinition(document.RootElement); + return DeserializeNoAuthenticationCredentials(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/NoAuthenticationCredentials.cs b/sdk/ai/Azure.AI.Projects/src/Generated/NoAuthenticationCredentials.cs new file mode 100644 index 000000000000..fc049c3e628c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/NoAuthenticationCredentials.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Credentials that do not require authentication. + public partial class NoAuthenticationCredentials : BaseCredentials + { + /// Initializes a new instance of . + internal NoAuthenticationCredentials() + { + Type = CredentialType.None; + } + + /// Initializes a new instance of . + /// The type of credential used by the connection. + /// Keeps track of any properties unknown to the library. + internal NoAuthenticationCredentials(CredentialType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentObject.cs deleted file mode 100644 index 4b60fb3f9fac..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The OpenAIPageableListOfAgent_object. - internal readonly partial struct OpenAIPageableListOfAgentObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public OpenAIPageableListOfAgentObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static OpenAIPageableListOfAgentObject List { get; } = new OpenAIPageableListOfAgentObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(OpenAIPageableListOfAgentObject left, OpenAIPageableListOfAgentObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(OpenAIPageableListOfAgentObject left, OpenAIPageableListOfAgentObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator OpenAIPageableListOfAgentObject(string value) => new OpenAIPageableListOfAgentObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIPageableListOfAgentObject other && Equals(other); - /// - public bool Equals(OpenAIPageableListOfAgentObject 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/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs deleted file mode 100644 index 275833d642ea..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs +++ /dev/null @@ -1,190 +0,0 @@ -// 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 -{ - internal partial class OpenAIPageableListOfAgentThread : 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(OpenAIPageableListOfAgentThread)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - 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 - } - } - } - - OpenAIPageableListOfAgentThread 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(OpenAIPageableListOfAgentThread)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenAIPageableListOfAgentThread(document.RootElement, options); - } - - internal static OpenAIPageableListOfAgentThread DeserializeOpenAIPageableListOfAgentThread(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenAIPageableListOfAgentThreadObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("object"u8)) - { - @object = new OpenAIPageableListOfAgentThreadObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(AgentThread.DeserializeAgentThread(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new OpenAIPageableListOfAgentThread( - @object, - data, - firstId, - lastId, - hasMore, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenAIPageableListOfAgentThread)} does not support writing '{options.Format}' format."); - } - } - - OpenAIPageableListOfAgentThread 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 DeserializeOpenAIPageableListOfAgentThread(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenAIPageableListOfAgentThread)} 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 OpenAIPageableListOfAgentThread FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenAIPageableListOfAgentThread(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/OpenAIPageableListOfAgentThread.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.cs deleted file mode 100644 index 5fcae9960350..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.cs +++ /dev/null @@ -1,101 +0,0 @@ -// 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 -{ - /// The response data for a requested list of items. - internal partial class OpenAIPageableListOfAgentThread - { - /// - /// 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 requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// , or is null. - internal OpenAIPageableListOfAgentThread(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - /// Initializes a new instance of . - /// The object type, which is always list. - /// The requested list of items. - /// The first ID represented in this list. - /// The last ID represented in this list. - /// A value indicating whether there are additional values available not captured in this list. - /// Keeps track of any properties unknown to the library. - internal OpenAIPageableListOfAgentThread(OpenAIPageableListOfAgentThreadObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal OpenAIPageableListOfAgentThread() - { - } - - /// The object type, which is always list. - public OpenAIPageableListOfAgentThreadObject Object { get; } = OpenAIPageableListOfAgentThreadObject.List; - - /// The requested list of items. - public IReadOnlyList Data { get; } - /// The first ID represented in this list. - public string FirstId { get; } - /// The last ID represented in this list. - public string LastId { get; } - /// A value indicating whether there are additional values available not captured in this list. - public bool HasMore { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThreadObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThreadObject.cs deleted file mode 100644 index 08aad6c532f8..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThreadObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The OpenAIPageableListOfAgentThread_object. - internal readonly partial struct OpenAIPageableListOfAgentThreadObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public OpenAIPageableListOfAgentThreadObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static OpenAIPageableListOfAgentThreadObject List { get; } = new OpenAIPageableListOfAgentThreadObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(OpenAIPageableListOfAgentThreadObject left, OpenAIPageableListOfAgentThreadObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(OpenAIPageableListOfAgentThreadObject left, OpenAIPageableListOfAgentThreadObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator OpenAIPageableListOfAgentThreadObject(string value) => new OpenAIPageableListOfAgentThreadObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIPageableListOfAgentThreadObject other && Equals(other); - /// - public bool Equals(OpenAIPageableListOfAgentThreadObject 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/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfRunStepObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfRunStepObject.cs deleted file mode 100644 index 5e8c1a1ffd1a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfRunStepObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The OpenAIPageableListOfRunStep_object. - internal readonly partial struct OpenAIPageableListOfRunStepObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public OpenAIPageableListOfRunStepObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static OpenAIPageableListOfRunStepObject List { get; } = new OpenAIPageableListOfRunStepObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(OpenAIPageableListOfRunStepObject left, OpenAIPageableListOfRunStepObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(OpenAIPageableListOfRunStepObject left, OpenAIPageableListOfRunStepObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator OpenAIPageableListOfRunStepObject(string value) => new OpenAIPageableListOfRunStepObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIPageableListOfRunStepObject other && Equals(other); - /// - public bool Equals(OpenAIPageableListOfRunStepObject 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/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfThreadMessageObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfThreadMessageObject.cs deleted file mode 100644 index 6731097a1547..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfThreadMessageObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The OpenAIPageableListOfThreadMessage_object. - internal readonly partial struct OpenAIPageableListOfThreadMessageObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public OpenAIPageableListOfThreadMessageObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static OpenAIPageableListOfThreadMessageObject List { get; } = new OpenAIPageableListOfThreadMessageObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(OpenAIPageableListOfThreadMessageObject left, OpenAIPageableListOfThreadMessageObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(OpenAIPageableListOfThreadMessageObject left, OpenAIPageableListOfThreadMessageObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator OpenAIPageableListOfThreadMessageObject(string value) => new OpenAIPageableListOfThreadMessageObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIPageableListOfThreadMessageObject other && Equals(other); - /// - public bool Equals(OpenAIPageableListOfThreadMessageObject 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/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfThreadRunObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfThreadRunObject.cs deleted file mode 100644 index 3a2f9d250bb6..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfThreadRunObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The OpenAIPageableListOfThreadRun_object. - internal readonly partial struct OpenAIPageableListOfThreadRunObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public OpenAIPageableListOfThreadRunObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static OpenAIPageableListOfThreadRunObject List { get; } = new OpenAIPageableListOfThreadRunObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(OpenAIPageableListOfThreadRunObject left, OpenAIPageableListOfThreadRunObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(OpenAIPageableListOfThreadRunObject left, OpenAIPageableListOfThreadRunObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator OpenAIPageableListOfThreadRunObject(string value) => new OpenAIPageableListOfThreadRunObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIPageableListOfThreadRunObject other && Equals(other); - /// - public bool Equals(OpenAIPageableListOfThreadRunObject 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/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs deleted file mode 100644 index 5f9aae0a88c7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 OpenApiAnonymousAuthDetails : 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(OpenApiAnonymousAuthDetails)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - OpenApiAnonymousAuthDetails 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(OpenApiAnonymousAuthDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiAnonymousAuthDetails(document.RootElement, options); - } - - internal static OpenApiAnonymousAuthDetails DeserializeOpenApiAnonymousAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenApiAuthType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new OpenApiAuthType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new OpenApiAnonymousAuthDetails(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} does not support writing '{options.Format}' format."); - } - } - - OpenApiAnonymousAuthDetails 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 DeserializeOpenApiAnonymousAuthDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} 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 OpenApiAnonymousAuthDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiAnonymousAuthDetails(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/OpenApiAnonymousAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.cs deleted file mode 100644 index 5a86750c6c95..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Security details for OpenApi anonymous authentication. - public partial class OpenApiAnonymousAuthDetails : OpenApiAuthDetails - { - /// Initializes a new instance of . - public OpenApiAnonymousAuthDetails() - { - Type = OpenApiAuthType.Anonymous; - } - - /// Initializes a new instance of . - /// The type of authentication, must be anonymous/connection/managed_identity. - /// Keeps track of any properties unknown to the library. - internal OpenApiAnonymousAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.cs deleted file mode 100644 index 596d594a2488..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// authentication details for OpenApiFunctionDefinition - /// 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 OpenApiAuthDetails - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected OpenApiAuthDetails() - { - } - - /// Initializes a new instance of . - /// The type of authentication, must be anonymous/connection/managed_identity. - /// Keeps track of any properties unknown to the library. - internal OpenApiAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The type of authentication, must be anonymous/connection/managed_identity. - internal OpenApiAuthType Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthType.cs deleted file mode 100644 index 230257cdbd7b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthType.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// - /// Authentication type for OpenApi endpoint. Allowed types are: - /// - Anonymous (no authentication required) - /// - Connection (requires connection_id to endpoint, as setup in AI Foundry) - /// - Managed_Identity (requires audience for identity based auth) - /// - internal readonly partial struct OpenApiAuthType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public OpenApiAuthType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AnonymousValue = "anonymous"; - private const string ConnectionValue = "connection"; - private const string ManagedIdentityValue = "managed_identity"; - - /// anonymous. - public static OpenApiAuthType Anonymous { get; } = new OpenApiAuthType(AnonymousValue); - /// connection. - public static OpenApiAuthType Connection { get; } = new OpenApiAuthType(ConnectionValue); - /// managed_identity. - public static OpenApiAuthType ManagedIdentity { get; } = new OpenApiAuthType(ManagedIdentityValue); - /// Determines if two values are the same. - public static bool operator ==(OpenApiAuthType left, OpenApiAuthType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(OpenApiAuthType left, OpenApiAuthType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator OpenApiAuthType(string value) => new OpenApiAuthType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenApiAuthType other && Equals(other); - /// - public bool Equals(OpenApiAuthType 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/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionAuthDetails.Serialization.cs deleted file mode 100644 index b60046b7233e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionAuthDetails.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 OpenApiConnectionAuthDetails : 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(OpenApiConnectionAuthDetails)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("security_scheme"u8); - writer.WriteObjectValue(SecurityScheme, options); - } - - OpenApiConnectionAuthDetails 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(OpenApiConnectionAuthDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiConnectionAuthDetails(document.RootElement, options); - } - - internal static OpenApiConnectionAuthDetails DeserializeOpenApiConnectionAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenApiConnectionSecurityScheme securityScheme = default; - OpenApiAuthType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("security_scheme"u8)) - { - securityScheme = OpenApiConnectionSecurityScheme.DeserializeOpenApiConnectionSecurityScheme(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new OpenApiAuthType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new OpenApiConnectionAuthDetails(type, serializedAdditionalRawData, securityScheme); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenApiConnectionAuthDetails)} does not support writing '{options.Format}' format."); - } - } - - OpenApiConnectionAuthDetails 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 DeserializeOpenApiConnectionAuthDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenApiConnectionAuthDetails)} 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 OpenApiConnectionAuthDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiConnectionAuthDetails(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/OpenApiConnectionAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionAuthDetails.cs deleted file mode 100644 index 8c2771c0f3b9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionAuthDetails.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Security details for OpenApi connection authentication. - public partial class OpenApiConnectionAuthDetails : OpenApiAuthDetails - { - /// Initializes a new instance of . - /// Connection auth security details. - /// is null. - public OpenApiConnectionAuthDetails(OpenApiConnectionSecurityScheme securityScheme) - { - Argument.AssertNotNull(securityScheme, nameof(securityScheme)); - - Type = OpenApiAuthType.Connection; - SecurityScheme = securityScheme; - } - - /// Initializes a new instance of . - /// The type of authentication, must be anonymous/connection/managed_identity. - /// Keeps track of any properties unknown to the library. - /// Connection auth security details. - internal OpenApiConnectionAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData, OpenApiConnectionSecurityScheme securityScheme) : base(type, serializedAdditionalRawData) - { - SecurityScheme = securityScheme; - } - - /// Initializes a new instance of for deserialization. - internal OpenApiConnectionAuthDetails() - { - } - - /// Connection auth security details. - public OpenApiConnectionSecurityScheme SecurityScheme { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionSecurityScheme.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionSecurityScheme.Serialization.cs deleted file mode 100644 index 97b215184bfc..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionSecurityScheme.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 OpenApiConnectionSecurityScheme : 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(OpenApiConnectionSecurityScheme)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("connection_id"u8); - writer.WriteStringValue(ConnectionId); - 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 - } - } - } - - OpenApiConnectionSecurityScheme 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(OpenApiConnectionSecurityScheme)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiConnectionSecurityScheme(document.RootElement, options); - } - - internal static OpenApiConnectionSecurityScheme DeserializeOpenApiConnectionSecurityScheme(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string connectionId = 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 (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new OpenApiConnectionSecurityScheme(connectionId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenApiConnectionSecurityScheme)} does not support writing '{options.Format}' format."); - } - } - - OpenApiConnectionSecurityScheme 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 DeserializeOpenApiConnectionSecurityScheme(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenApiConnectionSecurityScheme)} 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 OpenApiConnectionSecurityScheme FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiConnectionSecurityScheme(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/OpenApiConnectionSecurityScheme.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionSecurityScheme.cs deleted file mode 100644 index d74d1bae8a27..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiConnectionSecurityScheme.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Security scheme for OpenApi managed_identity authentication. - public partial class OpenApiConnectionSecurityScheme - { - /// - /// 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 . - /// Connection id for Connection auth type. - /// is null. - public OpenApiConnectionSecurityScheme(string connectionId) - { - Argument.AssertNotNull(connectionId, nameof(connectionId)); - - ConnectionId = connectionId; - } - - /// Initializes a new instance of . - /// Connection id for Connection auth type. - /// Keeps track of any properties unknown to the library. - internal OpenApiConnectionSecurityScheme(string connectionId, IDictionary serializedAdditionalRawData) - { - ConnectionId = connectionId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal OpenApiConnectionSecurityScheme() - { - } - - /// Connection id for Connection auth type. - public string ConnectionId { 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 deleted file mode 100644 index 26fccbb0ac9c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs +++ /dev/null @@ -1,207 +0,0 @@ -// 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 OpenApiFunctionDefinition : 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(OpenApiFunctionDefinition)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - writer.WritePropertyName("spec"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Spec); -#else - using (JsonDocument document = JsonDocument.Parse(Spec, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#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) - { - 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 - } - } - } - - OpenApiFunctionDefinition 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(OpenApiFunctionDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiFunctionDefinition(document.RootElement, options); - } - - internal static OpenApiFunctionDefinition DeserializeOpenApiFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - 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()) - { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("description"u8)) - { - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("spec"u8)) - { - spec = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("auth"u8)) - { - 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, - defaultParams ?? 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} does not support writing '{options.Format}' format."); - } - } - - OpenApiFunctionDefinition 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 DeserializeOpenApiFunctionDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} 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 OpenApiFunctionDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiFunctionDefinition(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/OpenApiFunctionDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs deleted file mode 100644 index b6ace6e72956..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs +++ /dev/null @@ -1,139 +0,0 @@ -// 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 an openapi function. - public partial class OpenApiFunctionDefinition - { - /// - /// 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 name of the function to be called. - /// The openapi function shape, described as a JSON Schema object. - /// - /// Open API authentication details - /// 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 . - /// - /// , or is null. - public OpenApiFunctionDefinition(string name, BinaryData spec, OpenApiAuthDetails auth) - { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(spec, nameof(spec)); - Argument.AssertNotNull(auth, nameof(auth)); - - Name = name; - Spec = spec; - Auth = auth; - DefaultParams = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The name of the function to be called. - /// A description of what the function does, used by the model to choose when and how to call the function. - /// The openapi function shape, described as a JSON Schema object. - /// - /// Open API authentication details - /// 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, IList defaultParams, IDictionary serializedAdditionalRawData) - { - Name = name; - Description = description; - Spec = spec; - Auth = auth; - DefaultParams = defaultParams; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal OpenApiFunctionDefinition() - { - } - - /// The name of the function to be called. - public string Name { get; set; } - /// A description of what the function does, used by the model to choose when and how to call the function. - public string Description { get; set; } - /// - /// The openapi function shape, described as a JSON Schema object. - /// - /// To assign an object to 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" }. - /// - /// - /// - /// - public BinaryData Spec { get; set; } - /// - /// Open API authentication details - /// 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 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/OpenApiManagedAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.Serialization.cs deleted file mode 100644 index 8189b5d52434..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 OpenApiManagedAuthDetails : 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(OpenApiManagedAuthDetails)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("security_scheme"u8); - writer.WriteObjectValue(SecurityScheme, options); - } - - OpenApiManagedAuthDetails 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(OpenApiManagedAuthDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiManagedAuthDetails(document.RootElement, options); - } - - internal static OpenApiManagedAuthDetails DeserializeOpenApiManagedAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenApiManagedSecurityScheme securityScheme = default; - OpenApiAuthType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("security_scheme"u8)) - { - securityScheme = OpenApiManagedSecurityScheme.DeserializeOpenApiManagedSecurityScheme(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new OpenApiAuthType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new OpenApiManagedAuthDetails(type, serializedAdditionalRawData, securityScheme); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} does not support writing '{options.Format}' format."); - } - } - - OpenApiManagedAuthDetails 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 DeserializeOpenApiManagedAuthDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} 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 OpenApiManagedAuthDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiManagedAuthDetails(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/OpenApiManagedAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.cs deleted file mode 100644 index 9a51a510225c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Security details for OpenApi managed_identity authentication. - public partial class OpenApiManagedAuthDetails : OpenApiAuthDetails - { - /// Initializes a new instance of . - /// Connection auth security details. - /// is null. - public OpenApiManagedAuthDetails(OpenApiManagedSecurityScheme securityScheme) - { - Argument.AssertNotNull(securityScheme, nameof(securityScheme)); - - Type = OpenApiAuthType.ManagedIdentity; - SecurityScheme = securityScheme; - } - - /// Initializes a new instance of . - /// The type of authentication, must be anonymous/connection/managed_identity. - /// Keeps track of any properties unknown to the library. - /// Connection auth security details. - internal OpenApiManagedAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData, OpenApiManagedSecurityScheme securityScheme) : base(type, serializedAdditionalRawData) - { - SecurityScheme = securityScheme; - } - - /// Initializes a new instance of for deserialization. - internal OpenApiManagedAuthDetails() - { - } - - /// Connection auth security details. - public OpenApiManagedSecurityScheme SecurityScheme { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs deleted file mode 100644 index 36794d4deb51..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 OpenApiManagedSecurityScheme : 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(OpenApiManagedSecurityScheme)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("audience"u8); - writer.WriteStringValue(Audience); - 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 - } - } - } - - OpenApiManagedSecurityScheme 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(OpenApiManagedSecurityScheme)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiManagedSecurityScheme(document.RootElement, options); - } - - internal static OpenApiManagedSecurityScheme DeserializeOpenApiManagedSecurityScheme(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string audience = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("audience"u8)) - { - audience = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new OpenApiManagedSecurityScheme(audience, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support writing '{options.Format}' format."); - } - } - - OpenApiManagedSecurityScheme 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 DeserializeOpenApiManagedSecurityScheme(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} 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 OpenApiManagedSecurityScheme FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiManagedSecurityScheme(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/OpenApiManagedSecurityScheme.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.cs deleted file mode 100644 index e1c3d9970098..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Security scheme for OpenApi managed_identity authentication. - public partial class OpenApiManagedSecurityScheme - { - /// - /// 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 . - /// Authentication scope for managed_identity auth type. - /// is null. - public OpenApiManagedSecurityScheme(string audience) - { - Argument.AssertNotNull(audience, nameof(audience)); - - Audience = audience; - } - - /// Initializes a new instance of . - /// Authentication scope for managed_identity auth type. - /// Keeps track of any properties unknown to the library. - internal OpenApiManagedSecurityScheme(string audience, IDictionary serializedAdditionalRawData) - { - Audience = audience; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal OpenApiManagedSecurityScheme() - { - } - - /// Authentication scope for managed_identity auth type. - public string Audience { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiToolDefinition.Serialization.cs deleted file mode 100644 index e5d90cf0a181..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiToolDefinition.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 OpenApiToolDefinition : 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(OpenApiToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("openapi"u8); - writer.WriteObjectValue(Openapi, options); - } - - OpenApiToolDefinition 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(OpenApiToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiToolDefinition(document.RootElement, options); - } - - internal static OpenApiToolDefinition DeserializeOpenApiToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenApiFunctionDefinition openapi = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("openapi"u8)) - { - openapi = OpenApiFunctionDefinition.DeserializeOpenApiFunctionDefinition(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 OpenApiToolDefinition(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenApiToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - OpenApiToolDefinition 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 DeserializeOpenApiToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenApiToolDefinition)} 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 OpenApiToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeOpenApiToolDefinition(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/OpenApiToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiToolDefinition.cs deleted file mode 100644 index f56708e3d6e5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiToolDefinition.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 an OpenAPI tool as used to configure an agent. - public partial class OpenApiToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - /// The openapi function definition. - /// is null. - public OpenApiToolDefinition(OpenApiFunctionDefinition openapi) - { - Argument.AssertNotNull(openapi, nameof(openapi)); - - Type = "openapi"; - Openapi = openapi; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The openapi function definition. - internal OpenApiToolDefinition(string type, IDictionary serializedAdditionalRawData, OpenApiFunctionDefinition openapi) : base(type, serializedAdditionalRawData) - { - Openapi = openapi; - } - - /// Initializes a new instance of for deserialization. - internal OpenApiToolDefinition() - { - } - - /// The openapi function definition. - public OpenApiFunctionDefinition Openapi { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMessageRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadRequest.Serialization.cs similarity index 61% rename from sdk/ai/Azure.AI.Projects/src/Generated/UpdateMessageRequest.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadRequest.Serialization.cs index acb9356ba625..8ee48f049445 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMessageRequest.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadRequest.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class UpdateMessageRequest : IUtf8JsonSerializable, IJsonModel + public partial class PendingUploadRequest : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,30 +28,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(PendingUploadRequest)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Metadata)) + if (Optional.IsDefined(PendingUploadId)) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WritePropertyName("pendingUploadId"u8); + writer.WriteStringValue(PendingUploadId); + } + if (Optional.IsDefined(ConnectionName)) + { + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); } + writer.WritePropertyName("pendingUploadType"u8); + writer.WriteStringValue(PendingUploadType.ToString()); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -69,19 +63,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - UpdateMessageRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + PendingUploadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(PendingUploadRequest)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUpdateMessageRequest(document.RootElement, options); + return DeserializePendingUploadRequest(document.RootElement, options); } - internal static UpdateMessageRequest DeserializeUpdateMessageRequest(JsonElement element, ModelReaderWriterOptions options = null) + internal static PendingUploadRequest DeserializePendingUploadRequest(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -89,23 +83,26 @@ internal static UpdateMessageRequest DeserializeUpdateMessageRequest(JsonElement { return null; } - IReadOnlyDictionary metadata = default; + string pendingUploadId = default; + string connectionName = default; + PendingUploadType pendingUploadType = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("metadata"u8)) + if (property.NameEquals("pendingUploadId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; + pendingUploadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("pendingUploadType"u8)) + { + pendingUploadType = new PendingUploadType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -114,46 +111,46 @@ internal static UpdateMessageRequest DeserializeUpdateMessageRequest(JsonElement } } serializedAdditionalRawData = rawDataDictionary; - return new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new PendingUploadRequest(pendingUploadId, connectionName, pendingUploadType, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(PendingUploadRequest)} does not support writing '{options.Format}' format."); } } - UpdateMessageRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + PendingUploadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateMessageRequest(document.RootElement, options); + return DeserializePendingUploadRequest(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(PendingUploadRequest)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static UpdateMessageRequest FromResponse(Response response) + internal static PendingUploadRequest FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateMessageRequest(document.RootElement); + return DeserializePendingUploadRequest(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadRequest.cs similarity index 55% rename from sdk/ai/Azure.AI.Projects/src/Generated/ToolOutput.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadRequest.cs index 4be9c96993c8..33ab5a20a0dd 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolOutput.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadRequest.cs @@ -10,8 +10,8 @@ namespace Azure.AI.Projects { - /// The data provided during a tool outputs submission to resolve pending tool calls and allow the model to continue. - public partial class ToolOutput + /// Represents a request for a pending upload. + public partial class PendingUploadRequest { /// /// Keeps track of any properties unknown to the library. @@ -45,25 +45,29 @@ public partial class ToolOutput /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - public ToolOutput() + /// Initializes a new instance of . + public PendingUploadRequest() { } - /// Initializes a new instance of . - /// The ID of the tool call being resolved, as provided in the tool calls of a required action from a run. - /// The output from the tool to be submitted. + /// Initializes a new instance of . + /// If PendingUploadId is not provided, a random GUID will be used. + /// Azure Storage Account connection name to use for generating temporary SAS token. + /// BlobReference is the only supported type. /// Keeps track of any properties unknown to the library. - internal ToolOutput(string toolCallId, string output, IDictionary serializedAdditionalRawData) + internal PendingUploadRequest(string pendingUploadId, string connectionName, PendingUploadType pendingUploadType, IDictionary serializedAdditionalRawData) { - ToolCallId = toolCallId; - Output = output; + PendingUploadId = pendingUploadId; + ConnectionName = connectionName; + PendingUploadType = pendingUploadType; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// The ID of the tool call being resolved, as provided in the tool calls of a required action from a run. - public string ToolCallId { get; set; } - /// The output from the tool to be submitted. - public string Output { get; set; } + /// If PendingUploadId is not provided, a random GUID will be used. + public string PendingUploadId { get; set; } + /// Azure Storage Account connection name to use for generating temporary SAS token. + public string ConnectionName { get; set; } + /// BlobReference is the only supported type. + public PendingUploadType PendingUploadType { get; } = PendingUploadType.BlobReference; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadResponse.Serialization.cs similarity index 59% rename from sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentDetails.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadResponse.Serialization.cs index 714a6739f5d5..e8f43260f3bd 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectedAgentDetails.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadResponse.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class ConnectedAgentDetails : IUtf8JsonSerializable, IJsonModel + public partial class PendingUploadResponse : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,18 +28,23 @@ 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ConnectedAgentDetails)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(PendingUploadResponse)} does not support writing '{format}' format."); } - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); + writer.WritePropertyName("blobReference"u8); + writer.WriteObjectValue(BlobReference, options); + writer.WritePropertyName("pendingUploadId"u8); + writer.WriteStringValue(PendingUploadId); + if (Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + writer.WritePropertyName("pendingUploadType"u8); + writer.WriteStringValue(PendingUploadType.ToString()); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -57,19 +62,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ConnectedAgentDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + PendingUploadResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ConnectedAgentDetails)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(PendingUploadResponse)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeConnectedAgentDetails(document.RootElement, options); + return DeserializePendingUploadResponse(document.RootElement, options); } - internal static ConnectedAgentDetails DeserializeConnectedAgentDetails(JsonElement element, ModelReaderWriterOptions options = null) + internal static PendingUploadResponse DeserializePendingUploadResponse(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,26 +82,32 @@ internal static ConnectedAgentDetails DeserializeConnectedAgentDetails(JsonEleme { return null; } - string id = default; - string name = default; - string description = default; + BlobReference blobReference = default; + string pendingUploadId = default; + string version = default; + PendingUploadType pendingUploadType = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (property.NameEquals("blobReference"u8)) + { + blobReference = BlobReference.DeserializeBlobReference(property.Value, options); + continue; + } + if (property.NameEquals("pendingUploadId"u8)) { - id = property.Value.GetString(); + pendingUploadId = property.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (property.NameEquals("version"u8)) { - name = property.Value.GetString(); + version = property.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (property.NameEquals("pendingUploadType"u8)) { - description = property.Value.GetString(); + pendingUploadType = new PendingUploadType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -105,46 +116,46 @@ internal static ConnectedAgentDetails DeserializeConnectedAgentDetails(JsonEleme } } serializedAdditionalRawData = rawDataDictionary; - return new ConnectedAgentDetails(id, name, description, serializedAdditionalRawData); + return new PendingUploadResponse(blobReference, pendingUploadId, version, pendingUploadType, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(ConnectedAgentDetails)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(PendingUploadResponse)} does not support writing '{options.Format}' format."); } } - ConnectedAgentDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + PendingUploadResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeConnectedAgentDetails(document.RootElement, options); + return DeserializePendingUploadResponse(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(ConnectedAgentDetails)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(PendingUploadResponse)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static ConnectedAgentDetails FromResponse(Response response) + internal static PendingUploadResponse FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeConnectedAgentDetails(document.RootElement); + return DeserializePendingUploadResponse(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadResponse.cs new file mode 100644 index 000000000000..accce225f1ea --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadResponse.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Represents the response for a pending upload request. + public partial class PendingUploadResponse + { + /// + /// 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 . + /// Container-level read, write, list SAS. + /// ID for this upload request. + /// or is null. + internal PendingUploadResponse(BlobReference blobReference, string pendingUploadId) + { + Argument.AssertNotNull(blobReference, nameof(blobReference)); + Argument.AssertNotNull(pendingUploadId, nameof(pendingUploadId)); + + BlobReference = blobReference; + PendingUploadId = pendingUploadId; + } + + /// Initializes a new instance of . + /// Container-level read, write, list SAS. + /// ID for this upload request. + /// Version of asset to be created if user did not specify version when initially creating upload. + /// BlobReference is the only supported type. + /// Keeps track of any properties unknown to the library. + internal PendingUploadResponse(BlobReference blobReference, string pendingUploadId, string version, PendingUploadType pendingUploadType, IDictionary serializedAdditionalRawData) + { + BlobReference = blobReference; + PendingUploadId = pendingUploadId; + Version = version; + PendingUploadType = pendingUploadType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PendingUploadResponse() + { + } + + /// Container-level read, write, list SAS. + public BlobReference BlobReference { get; } + /// ID for this upload request. + public string PendingUploadId { get; } + /// Version of asset to be created if user did not specify version when initially creating upload. + public string Version { get; } + /// BlobReference is the only supported type. + public PendingUploadType PendingUploadType { get; } = PendingUploadType.BlobReference; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadType.cs new file mode 100644 index 000000000000..241a6edb544e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PendingUploadType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The type of pending upload. + public readonly partial struct PendingUploadType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PendingUploadType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string BlobReferenceValue = "BlobReference"; + + /// No pending upload. + public static PendingUploadType None { get; } = new PendingUploadType(NoneValue); + /// Blob Reference is the only supported type. + public static PendingUploadType BlobReference { get; } = new PendingUploadType(BlobReferenceValue); + /// Determines if two values are the same. + public static bool operator ==(PendingUploadType left, PendingUploadType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PendingUploadType left, PendingUploadType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PendingUploadType(string value) => new PendingUploadType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PendingUploadType other && Equals(other); + /// + public bool Equals(PendingUploadType 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/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.cs deleted file mode 100644 index 5caa77ae3151..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.cs +++ /dev/null @@ -1,93 +0,0 @@ -// 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 -{ - /// RecurrenceSchedule Definition. - public partial class RecurrenceSchedule - { - /// - /// 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 . - /// List of hours for the schedule. - /// List of minutes for the schedule. - /// or is null. - public RecurrenceSchedule(IEnumerable hours, IEnumerable minutes) - { - Argument.AssertNotNull(hours, nameof(hours)); - Argument.AssertNotNull(minutes, nameof(minutes)); - - Hours = hours.ToList(); - Minutes = minutes.ToList(); - WeekDays = new ChangeTrackingList(); - MonthDays = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// List of hours for the schedule. - /// List of minutes for the schedule. - /// List of days for the schedule. - /// List of month days for the schedule. - /// Keeps track of any properties unknown to the library. - internal RecurrenceSchedule(IList hours, IList minutes, IList weekDays, IList monthDays, IDictionary serializedAdditionalRawData) - { - Hours = hours; - Minutes = minutes; - WeekDays = weekDays; - MonthDays = monthDays; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RecurrenceSchedule() - { - } - - /// List of hours for the schedule. - public IList Hours { get; } - /// List of minutes for the schedule. - public IList Minutes { get; } - /// List of days for the schedule. - public IList WeekDays { get; } - /// List of month days for the schedule. - public IList MonthDays { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.Serialization.cs deleted file mode 100644 index 1f4baf19002c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.Serialization.cs +++ /dev/null @@ -1,157 +0,0 @@ -// 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 RecurrenceTrigger : 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(RecurrenceTrigger)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("frequency"u8); - writer.WriteStringValue(Frequency.ToString()); - writer.WritePropertyName("interval"u8); - writer.WriteNumberValue(Interval); - if (Optional.IsDefined(Schedule)) - { - writer.WritePropertyName("schedule"u8); - writer.WriteObjectValue(Schedule, options); - } - } - - RecurrenceTrigger 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(RecurrenceTrigger)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRecurrenceTrigger(document.RootElement, options); - } - - internal static RecurrenceTrigger DeserializeRecurrenceTrigger(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - Frequency frequency = default; - int interval = default; - RecurrenceSchedule schedule = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("frequency"u8)) - { - frequency = new Frequency(property.Value.GetString()); - continue; - } - if (property.NameEquals("interval"u8)) - { - interval = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("schedule"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - schedule = RecurrenceSchedule.DeserializeRecurrenceSchedule(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 RecurrenceTrigger(type, serializedAdditionalRawData, frequency, interval, schedule); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RecurrenceTrigger)} does not support writing '{options.Format}' format."); - } - } - - RecurrenceTrigger 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 DeserializeRecurrenceTrigger(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RecurrenceTrigger)} 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 RecurrenceTrigger FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRecurrenceTrigger(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/RecurrenceTrigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.cs deleted file mode 100644 index 2d88ffb17eb1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Recurrence Trigger Definition. - public partial class RecurrenceTrigger : Trigger - { - /// Initializes a new instance of . - /// The frequency to trigger schedule. - /// Specifies schedule interval in conjunction with frequency. - public RecurrenceTrigger(Frequency frequency, int interval) - { - Type = "Recurrence"; - Frequency = frequency; - Interval = interval; - } - - /// Initializes a new instance of . - /// Type of the trigger. - /// Keeps track of any properties unknown to the library. - /// The frequency to trigger schedule. - /// Specifies schedule interval in conjunction with frequency. - /// The recurrence schedule. - internal RecurrenceTrigger(string type, IDictionary serializedAdditionalRawData, Frequency frequency, int interval, RecurrenceSchedule schedule) : base(type, serializedAdditionalRawData) - { - Frequency = frequency; - Interval = interval; - Schedule = schedule; - } - - /// Initializes a new instance of for deserialization. - internal RecurrenceTrigger() - { - } - - /// The frequency to trigger schedule. - public Frequency Frequency { get; set; } - /// Specifies schedule interval in conjunction with frequency. - public int Interval { get; set; } - /// The recurrence schedule. - public RecurrenceSchedule Schedule { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.Serialization.cs similarity index 53% rename from sdk/ai/Azure.AI.Projects/src/Generated/EvaluationSchedule.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.Serialization.cs index af0f860410c6..4565aa83f005 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationSchedule.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class EvaluationSchedule : IUtf8JsonSerializable, IJsonModel + public partial class RedTeam : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,33 +28,56 @@ 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(EvaluationSchedule)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(RedTeam)} does not support writing '{format}' format."); } if (options.Format != "W") { - writer.WritePropertyName("name"u8); + writer.WritePropertyName("id"u8); writer.WriteStringValue(Name); } - writer.WritePropertyName("data"u8); - writer.WriteObjectValue(Data, options); - if (Optional.IsDefined(Description)) + if (Optional.IsDefined(DisplayName)) { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); } - if (options.Format != "W" && Optional.IsDefined(SystemData)) + if (Optional.IsDefined(NumTurns)) { - writer.WritePropertyName("systemData"u8); - writer.WriteObjectValue(SystemData, options); + writer.WritePropertyName("numTurns"u8); + writer.WriteNumberValue(NumTurns.Value); } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + if (Optional.IsCollectionDefined(AttackStrategies)) { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState); + writer.WritePropertyName("attackStrategies"u8); + writer.WriteStartArray(); + foreach (var item in AttackStrategies) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(SimulationOnly)) + { + writer.WritePropertyName("simulationOnly"u8); + writer.WriteBooleanValue(SimulationOnly.Value); + } + if (Optional.IsCollectionDefined(RiskCategories)) + { + writer.WritePropertyName("riskCategories"u8); + writer.WriteStartArray(); + foreach (var item in RiskCategories) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ApplicationScenario)) + { + writer.WritePropertyName("applicationScenario"u8); + writer.WriteStringValue(ApplicationScenario); } if (Optional.IsCollectionDefined(Tags)) { @@ -78,21 +101,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WriteEndObject(); } - if (options.Format != "W" && Optional.IsDefined(IsEnabled)) + if (options.Format != "W" && Optional.IsDefined(Status)) { - writer.WritePropertyName("isEnabled"u8); - writer.WriteStringValue(IsEnabled); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); } - writer.WritePropertyName("evaluators"u8); - writer.WriteStartObject(); - foreach (var item in Evaluators) - { - writer.WritePropertyName(item.Key); - writer.WriteObjectValue(item.Value, options); - } - writer.WriteEndObject(); - writer.WritePropertyName("trigger"u8); - writer.WriteObjectValue(Trigger, options); + writer.WritePropertyName("target"u8); + writer.WriteObjectValue(Target, options); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -110,19 +125,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - EvaluationSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RedTeam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(EvaluationSchedule)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(RedTeam)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeEvaluationSchedule(document.RootElement, options); + return DeserializeRedTeam(document.RootElement, options); } - internal static EvaluationSchedule DeserializeEvaluationSchedule(JsonElement element, ModelReaderWriterOptions options = null) + internal static RedTeam DeserializeRedTeam(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -130,47 +145,80 @@ internal static EvaluationSchedule DeserializeEvaluationSchedule(JsonElement ele { return null; } - string name = default; - ApplicationInsightsConfiguration data = default; - string description = default; - SystemData systemData = default; - string provisioningState = default; + string id = default; + string displayName = default; + int? numTurns = default; + IList attackStrategies = default; + bool? simulationOnly = default; + IList riskCategories = default; + string applicationScenario = default; IDictionary tags = default; IDictionary properties = default; - string isEnabled = default; - IDictionary evaluators = default; - Trigger trigger = default; + string status = default; + TargetConfig target = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) { - name = property.Value.GetString(); + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("numTurns"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + numTurns = property.Value.GetInt32(); continue; } - if (property.NameEquals("data"u8)) + if (property.NameEquals("attackStrategies"u8)) { - data = ApplicationInsightsConfiguration.DeserializeApplicationInsightsConfiguration(property.Value, options); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AttackStrategy(item.GetString())); + } + attackStrategies = array; continue; } - if (property.NameEquals("description"u8)) + if (property.NameEquals("simulationOnly"u8)) { - description = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + simulationOnly = property.Value.GetBoolean(); continue; } - if (property.NameEquals("systemData"u8)) + if (property.NameEquals("riskCategories"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = SystemData.DeserializeSystemData(property.Value, options); + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new RiskCategory(item.GetString())); + } + riskCategories = array; continue; } - if (property.NameEquals("provisioningState"u8)) + if (property.NameEquals("applicationScenario"u8)) { - provisioningState = property.Value.GetString(); + applicationScenario = property.Value.GetString(); continue; } if (property.NameEquals("tags"u8)) @@ -201,24 +249,14 @@ internal static EvaluationSchedule DeserializeEvaluationSchedule(JsonElement ele properties = dictionary; continue; } - if (property.NameEquals("isEnabled"u8)) - { - isEnabled = property.Value.GetString(); - continue; - } - if (property.NameEquals("evaluators"u8)) + if (property.NameEquals("status"u8)) { - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, EvaluatorConfiguration.DeserializeEvaluatorConfiguration(property0.Value, options)); - } - evaluators = dictionary; + status = property.Value.GetString(); continue; } - if (property.NameEquals("trigger"u8)) + if (property.NameEquals("target"u8)) { - trigger = Trigger.DeserializeTrigger(property.Value, options); + target = TargetConfig.DeserializeTargetConfig(property.Value, options); continue; } if (options.Format != "W") @@ -227,57 +265,58 @@ internal static EvaluationSchedule DeserializeEvaluationSchedule(JsonElement ele } } serializedAdditionalRawData = rawDataDictionary; - return new EvaluationSchedule( - name, - data, - description, - systemData, - provisioningState, + return new RedTeam( + id, + displayName, + numTurns, + attackStrategies ?? new ChangeTrackingList(), + simulationOnly, + riskCategories ?? new ChangeTrackingList(), + applicationScenario, tags ?? new ChangeTrackingDictionary(), properties ?? new ChangeTrackingDictionary(), - isEnabled, - evaluators, - trigger, + status, + target, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(EvaluationSchedule)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(RedTeam)} does not support writing '{options.Format}' format."); } } - EvaluationSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + RedTeam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeEvaluationSchedule(document.RootElement, options); + return DeserializeRedTeam(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(EvaluationSchedule)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(RedTeam)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static EvaluationSchedule FromResponse(Response response) + internal static RedTeam FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeEvaluationSchedule(document.RootElement); + return DeserializeRedTeam(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.cs new file mode 100644 index 000000000000..b2bb39f82682 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.cs @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Red team details. + public partial class RedTeam + { + /// + /// 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 . + /// + /// Target configuration for the red-team 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 . + /// + /// is null. + public RedTeam(TargetConfig target) + { + Argument.AssertNotNull(target, nameof(target)); + + AttackStrategies = new ChangeTrackingList(); + RiskCategories = new ChangeTrackingList(); + Tags = new ChangeTrackingDictionary(); + Properties = new ChangeTrackingDictionary(); + Target = target; + } + + /// Initializes a new instance of . + /// Identifier of the red team run. + /// Name of the red-team run. + /// Number of simulation rounds. + /// List of attack strategies or nested lists of attack strategies. + /// Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. + /// List of risk categories to generate attack objectives for. + /// Application scenario for the red team operation, to generate scenario specific attacks. + /// Red team's tags. Unlike properties, tags are fully mutable. + /// Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + /// Status of the red-team. It is set by service and is read-only. + /// + /// Target configuration for the red-team 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 . + /// + /// Keeps track of any properties unknown to the library. + internal RedTeam(string name, string displayName, int? numTurns, IList attackStrategies, bool? simulationOnly, IList riskCategories, string applicationScenario, IDictionary tags, IDictionary properties, string status, TargetConfig target, IDictionary serializedAdditionalRawData) + { + Name = name; + DisplayName = displayName; + NumTurns = numTurns; + AttackStrategies = attackStrategies; + SimulationOnly = simulationOnly; + RiskCategories = riskCategories; + ApplicationScenario = applicationScenario; + Tags = tags; + Properties = properties; + Status = status; + Target = target; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RedTeam() + { + } + + /// Identifier of the red team run. + public string Name { get; } + /// Name of the red-team run. + public string DisplayName { get; set; } + /// Number of simulation rounds. + public int? NumTurns { get; set; } + /// List of attack strategies or nested lists of attack strategies. + public IList AttackStrategies { get; } + /// Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. + public bool? SimulationOnly { get; set; } + /// List of risk categories to generate attack objectives for. + public IList RiskCategories { get; } + /// Application scenario for the red team operation, to generate scenario specific attacks. + public string ApplicationScenario { get; set; } + /// Red team's tags. Unlike properties, tags are fully mutable. + public IDictionary Tags { get; } + /// Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + public IDictionary Properties { get; } + /// Status of the red-team. It is set by service and is read-only. + public string Status { get; } + /// + /// Target configuration for the red-team 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 . + /// + public TargetConfig Target { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.cs new file mode 100644 index 000000000000..a91cc1e1d65f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.cs @@ -0,0 +1,424 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects +{ + // Data plane generated sub-client. + /// The RedTeams sub-client. + public partial class RedTeams + { + private static readonly string[] AuthorizationScopes = new string[] { "https://ai.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of RedTeams for mocking. + protected RedTeams() + { + } + + /// Initializes a new instance of RedTeams. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// + /// The API version to use for this operation. + internal RedTeams(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get a redteam by name. + /// Identifier of the red team run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetRedTeamAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetRedTeamAsync(name, context).ConfigureAwait(false); + return Response.FromValue(RedTeam.FromResponse(response), response); + } + + /// Get a redteam by name. + /// Identifier of the red team run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetRedTeam(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetRedTeam(name, context); + return Response.FromValue(RedTeam.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get a redteam by name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the red team run. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetRedTeamAsync(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("RedTeams.GetRedTeam"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRedTeamRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get a redteam by name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the red team run. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetRedTeam(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("RedTeams.GetRedTeam"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRedTeamRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a redteam run. + /// Redteam to be run. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> CreateAsync(RedTeam redTeam, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(redTeam, nameof(redTeam)); + + using RequestContent content = redTeam.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateAsync(content, context).ConfigureAwait(false); + return Response.FromValue(RedTeam.FromResponse(response), response); + } + + /// Creates a redteam run. + /// Redteam to be run. + /// The cancellation token to use. + /// is null. + /// + public virtual Response Create(RedTeam redTeam, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(redTeam, nameof(redTeam)); + + using RequestContent content = redTeam.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Create(content, context); + return Response.FromValue(RedTeam.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a redteam run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("RedTeams.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a redteam run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Create(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("RedTeams.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List a redteam by name. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetRedTeamsAsync(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetRedTeamsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetRedTeamsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => RedTeam.DeserializeRedTeam(e), ClientDiagnostics, _pipeline, "RedTeams.GetRedTeams", "value", "nextLink", context); + } + + /// List a redteam by name. + /// The cancellation token to use. + /// + public virtual Pageable GetRedTeams(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetRedTeamsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetRedTeamsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => RedTeam.DeserializeRedTeam(e), ClientDiagnostics, _pipeline, "RedTeams.GetRedTeams", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List a redteam by name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetRedTeamsAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetRedTeamsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetRedTeamsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "RedTeams.GetRedTeams", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List a redteam by name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetRedTeams(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetRedTeamsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetRedTeamsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "RedTeams.GetRedTeams", "value", "nextLink", context); + } + + internal HttpMessage CreateGetRedTeamRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/redTeams/runs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetRedTeamsRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/redTeams/runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier201); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/redTeams/runs:run", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetRedTeamsNextPageRequest(string nextLink, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier201; + private static ResponseClassifier ResponseClassifier201 => _responseClassifier201 ??= new StatusCodeClassifier(stackalloc ushort[] { 201 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredFunctionToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RequiredFunctionToolCall.Serialization.cs deleted file mode 100644 index 47301674363b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredFunctionToolCall.Serialization.cs +++ /dev/null @@ -1,140 +0,0 @@ -// 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 RequiredFunctionToolCall : 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(RequiredFunctionToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(InternalDetails, options); - } - - RequiredFunctionToolCall 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(RequiredFunctionToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRequiredFunctionToolCall(document.RootElement, options); - } - - internal static RequiredFunctionToolCall DeserializeRequiredFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalRequiredFunctionToolCallDetails function = default; - string id = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("function"u8)) - { - function = InternalRequiredFunctionToolCallDetails.DeserializeInternalRequiredFunctionToolCallDetails(property.Value, options); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - 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 RequiredFunctionToolCall(type, serializedAdditionalRawData, id, function); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RequiredFunctionToolCall)} does not support writing '{options.Format}' format."); - } - } - - RequiredFunctionToolCall 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 DeserializeRequiredFunctionToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RequiredFunctionToolCall)} 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 RequiredFunctionToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRequiredFunctionToolCall(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/RequiredFunctionToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RequiredFunctionToolCall.cs deleted file mode 100644 index 259b963338fe..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredFunctionToolCall.cs +++ /dev/null @@ -1,43 +0,0 @@ -// 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 representation of a requested call to a function tool, needed by the model to continue evaluation of a run. - public partial class RequiredFunctionToolCall : RequiredToolCall - { - /// Initializes a new instance of . - /// The ID of the tool call. This ID must be referenced when submitting tool outputs. - /// Detailed information about the function to be executed by the tool that includes name and arguments. - /// or is null. - internal RequiredFunctionToolCall(string id, InternalRequiredFunctionToolCallDetails internalDetails) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(internalDetails, nameof(internalDetails)); - - InternalDetails = internalDetails; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The ID of the tool call. This ID must be referenced when submitting tool outputs. - /// Detailed information about the function to be executed by the tool that includes name and arguments. - internal RequiredFunctionToolCall(string type, IDictionary serializedAdditionalRawData, string id, InternalRequiredFunctionToolCallDetails internalDetails) : base(type, serializedAdditionalRawData, id) - { - InternalDetails = internalDetails; - } - - /// Initializes a new instance of for deserialization. - internal RequiredFunctionToolCall() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RequiredToolCall.Serialization.cs deleted file mode 100644 index 9f029022944a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredToolCall.Serialization.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownRequiredToolCall))] - public partial class RequiredToolCall : 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(RequiredToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - - RequiredToolCall 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(RequiredToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRequiredToolCall(document.RootElement, options); - } - - internal static RequiredToolCall DeserializeRequiredToolCall(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 "function": return RequiredFunctionToolCall.DeserializeRequiredFunctionToolCall(element, options); - } - } - return UnknownRequiredToolCall.DeserializeUnknownRequiredToolCall(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RequiredToolCall)} does not support writing '{options.Format}' format."); - } - } - - RequiredToolCall 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 DeserializeRequiredToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RequiredToolCall)} 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 RequiredToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRequiredToolCall(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/RequiredToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RequiredToolCall.cs deleted file mode 100644 index abeb4d7c18ec..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RequiredToolCall.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// An abstract representation of a tool invocation needed by the model to continue a 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 . - /// - public abstract partial class RequiredToolCall : RequiredAction - { - /// Initializes a new instance of . - /// The ID of the tool call. This ID must be referenced when submitting tool outputs. - /// is null. - protected RequiredToolCall(string id) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The ID of the tool call. This ID must be referenced when submitting tool outputs. - internal RequiredToolCall(string type, IDictionary serializedAdditionalRawData, string id) : base(type, serializedAdditionalRawData) - { - Id = id; - } - - /// Initializes a new instance of for deserialization. - internal RequiredToolCall() - { - } - - /// The ID of the tool call. This ID must be referenced when submitting tool outputs. - public string Id { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormat.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormat.cs deleted file mode 100644 index f14f7bea0d8c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormat.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Possible API response formats. - public readonly partial struct ResponseFormat : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public ResponseFormat(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string TextValue = "text"; - private const string JsonObjectValue = "json_object"; - - /// `text` format should be used for requests involving any sort of ToolCall. - public static ResponseFormat Text { get; } = new ResponseFormat(TextValue); - /// Using `json_object` format will limit the usage of ToolCall to only functions. - public static ResponseFormat JsonObject { get; } = new ResponseFormat(JsonObjectValue); - /// Determines if two values are the same. - public static bool operator ==(ResponseFormat left, ResponseFormat right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(ResponseFormat left, ResponseFormat right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator ResponseFormat(string value) => new ResponseFormat(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ResponseFormat other && Equals(other); - /// - public bool Equals(ResponseFormat 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/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchema.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchema.Serialization.cs deleted file mode 100644 index d10bc5b6b717..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchema.Serialization.cs +++ /dev/null @@ -1,168 +0,0 @@ -// 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 ResponseFormatJsonSchema : 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(ResponseFormatJsonSchema)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("schema"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Schema); -#else - using (JsonDocument document = JsonDocument.Parse(Schema, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - 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 - } - } - } - - ResponseFormatJsonSchema 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(ResponseFormatJsonSchema)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeResponseFormatJsonSchema(document.RootElement, options); - } - - internal static ResponseFormatJsonSchema DeserializeResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string description = default; - string name = default; - BinaryData schema = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("description"u8)) - { - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("schema"u8)) - { - schema = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ResponseFormatJsonSchema(description, name, schema, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ResponseFormatJsonSchema)} does not support writing '{options.Format}' format."); - } - } - - ResponseFormatJsonSchema 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 DeserializeResponseFormatJsonSchema(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ResponseFormatJsonSchema)} 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 ResponseFormatJsonSchema FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeResponseFormatJsonSchema(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/ResponseFormatJsonSchema.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchema.cs deleted file mode 100644 index 27c3e21c9b57..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchema.cs +++ /dev/null @@ -1,115 +0,0 @@ -// 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 description of what the response format is for, used by the model to determine how to respond in the format. - public partial class ResponseFormatJsonSchema - { - /// - /// 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 name of a schema. - /// The JSON schema object, describing the response format. - /// or is null. - public ResponseFormatJsonSchema(string name, BinaryData schema) - { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(schema, nameof(schema)); - - Name = name; - Schema = schema; - } - - /// Initializes a new instance of . - /// A description of what the response format is for, used by the model to determine how to respond in the format. - /// The name of a schema. - /// The JSON schema object, describing the response format. - /// Keeps track of any properties unknown to the library. - internal ResponseFormatJsonSchema(string description, string name, BinaryData schema, IDictionary serializedAdditionalRawData) - { - Description = description; - Name = name; - Schema = schema; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ResponseFormatJsonSchema() - { - } - - /// A description of what the response format is for, used by the model to determine how to respond in the format. - public string Description { get; set; } - /// The name of a schema. - public string Name { get; set; } - /// - /// The JSON schema object, describing the response format. - /// - /// To assign an object to 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" }. - /// - /// - /// - /// - public BinaryData Schema { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchemaType.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchemaType.Serialization.cs deleted file mode 100644 index 154289ef92df..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchemaType.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 ResponseFormatJsonSchemaType : 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(ResponseFormatJsonSchemaType)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - writer.WritePropertyName("json_schema"u8); - writer.WriteObjectValue(JsonSchema, options); - 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 - } - } - } - - ResponseFormatJsonSchemaType 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(ResponseFormatJsonSchemaType)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeResponseFormatJsonSchemaType(document.RootElement, options); - } - - internal static ResponseFormatJsonSchemaType DeserializeResponseFormatJsonSchemaType(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ResponseFormatJsonSchemaTypeType type = default; - ResponseFormatJsonSchema jsonSchema = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new ResponseFormatJsonSchemaTypeType(property.Value.GetString()); - continue; - } - if (property.NameEquals("json_schema"u8)) - { - jsonSchema = ResponseFormatJsonSchema.DeserializeResponseFormatJsonSchema(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ResponseFormatJsonSchemaType(type, jsonSchema, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ResponseFormatJsonSchemaType)} does not support writing '{options.Format}' format."); - } - } - - ResponseFormatJsonSchemaType 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 DeserializeResponseFormatJsonSchemaType(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ResponseFormatJsonSchemaType)} 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 ResponseFormatJsonSchemaType FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeResponseFormatJsonSchemaType(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/ResponseFormatJsonSchemaType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchemaType.cs deleted file mode 100644 index 8d0f76332659..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchemaType.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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 type of response format being defined: `json_schema`. - public partial class ResponseFormatJsonSchemaType - { - /// - /// 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 JSON schema, describing response format. - /// is null. - public ResponseFormatJsonSchemaType(ResponseFormatJsonSchema jsonSchema) - { - Argument.AssertNotNull(jsonSchema, nameof(jsonSchema)); - - JsonSchema = jsonSchema; - } - - /// Initializes a new instance of . - /// Type. - /// The JSON schema, describing response format. - /// Keeps track of any properties unknown to the library. - internal ResponseFormatJsonSchemaType(ResponseFormatJsonSchemaTypeType type, ResponseFormatJsonSchema jsonSchema, IDictionary serializedAdditionalRawData) - { - Type = type; - JsonSchema = jsonSchema; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ResponseFormatJsonSchemaType() - { - } - - /// Type. - public ResponseFormatJsonSchemaTypeType Type { get; } = ResponseFormatJsonSchemaTypeType.JsonSchema; - - /// The JSON schema, describing response format. - public ResponseFormatJsonSchema JsonSchema { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchemaTypeType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchemaTypeType.cs deleted file mode 100644 index c9c0b85cb3ec..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseFormatJsonSchemaTypeType.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The ResponseFormatJsonSchemaType_type. - public readonly partial struct ResponseFormatJsonSchemaTypeType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public ResponseFormatJsonSchemaTypeType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string JsonSchemaValue = "json_schema"; - - /// json_schema. - public static ResponseFormatJsonSchemaTypeType JsonSchema { get; } = new ResponseFormatJsonSchemaTypeType(JsonSchemaValue); - /// Determines if two values are the same. - public static bool operator ==(ResponseFormatJsonSchemaTypeType left, ResponseFormatJsonSchemaTypeType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(ResponseFormatJsonSchemaTypeType left, ResponseFormatJsonSchemaTypeType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator ResponseFormatJsonSchemaTypeType(string value) => new ResponseFormatJsonSchemaTypeType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ResponseFormatJsonSchemaTypeType other && Equals(other); - /// - public bool Equals(ResponseFormatJsonSchemaTypeType 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/sdk/ai/Azure.AI.Projects/src/Generated/RiskCategory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RiskCategory.cs new file mode 100644 index 000000000000..7fd9c7d9527a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RiskCategory.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Risk category for the attack objective. + public readonly partial struct RiskCategory : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RiskCategory(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string HateUnfairnessValue = "HateUnfairness"; + private const string ViolenceValue = "Violence"; + private const string SexualValue = "Sexual"; + private const string SelfHarmValue = "SelfHarm"; + + /// Represents content related to hate or unfairness. + public static RiskCategory HateUnfairness { get; } = new RiskCategory(HateUnfairnessValue); + /// Represents content related to violence. + public static RiskCategory Violence { get; } = new RiskCategory(ViolenceValue); + /// Represents content of a sexual nature. + public static RiskCategory Sexual { get; } = new RiskCategory(SexualValue); + /// Represents content related to self-harm. + public static RiskCategory SelfHarm { get; } = new RiskCategory(SelfHarmValue); + /// Determines if two values are the same. + public static bool operator ==(RiskCategory left, RiskCategory right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RiskCategory left, RiskCategory right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RiskCategory(string value) => new RiskCategory(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RiskCategory other && Equals(other); + /// + public bool Equals(RiskCategory 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/sdk/ai/Azure.AI.Projects/src/Generated/RunAdditionalFieldList.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunAdditionalFieldList.cs deleted file mode 100644 index 897785c4c0b9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunAdditionalFieldList.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// A list of additional fields to include in the response. - public readonly partial struct RunAdditionalFieldList : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RunAdditionalFieldList(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string FileSearchContentsValue = "step_details.tool_calls[*].file_search.results[*].content"; - - /// File search result content. - public static RunAdditionalFieldList FileSearchContents { get; } = new RunAdditionalFieldList(FileSearchContentsValue); - /// Determines if two values are the same. - public static bool operator ==(RunAdditionalFieldList left, RunAdditionalFieldList right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RunAdditionalFieldList left, RunAdditionalFieldList right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator RunAdditionalFieldList(string value) => new RunAdditionalFieldList(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunAdditionalFieldList other && Equals(other); - /// - public bool Equals(RunAdditionalFieldList 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/sdk/ai/Azure.AI.Projects/src/Generated/RunCompletionUsage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunCompletionUsage.Serialization.cs deleted file mode 100644 index 7f0d8e2a99ce..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunCompletionUsage.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 RunCompletionUsage : 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(RunCompletionUsage)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("completion_tokens"u8); - writer.WriteNumberValue(CompletionTokens); - writer.WritePropertyName("prompt_tokens"u8); - writer.WriteNumberValue(PromptTokens); - writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokens); - 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 - } - } - } - - RunCompletionUsage 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(RunCompletionUsage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunCompletionUsage(document.RootElement, options); - } - - internal static RunCompletionUsage DeserializeRunCompletionUsage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - long completionTokens = default; - long promptTokens = default; - long totalTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("completion_tokens"u8)) - { - completionTokens = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("prompt_tokens"u8)) - { - promptTokens = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("total_tokens"u8)) - { - totalTokens = property.Value.GetInt64(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunCompletionUsage(completionTokens, promptTokens, totalTokens, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support writing '{options.Format}' format."); - } - } - - RunCompletionUsage 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 DeserializeRunCompletionUsage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunCompletionUsage)} 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 RunCompletionUsage FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunCompletionUsage(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/RunCompletionUsage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunCompletionUsage.cs deleted file mode 100644 index 06340645c52d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunCompletionUsage.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - public partial class RunCompletionUsage - { - /// - /// 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 . - /// Number of completion tokens used over the course of the run. - /// Number of prompt tokens used over the course of the run. - /// Total number of tokens used (prompt + completion). - internal RunCompletionUsage(long completionTokens, long promptTokens, long totalTokens) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - } - - /// Initializes a new instance of . - /// Number of completion tokens used over the course of the run. - /// Number of prompt tokens used over the course of the run. - /// Total number of tokens used (prompt + completion). - /// Keeps track of any properties unknown to the library. - internal RunCompletionUsage(long completionTokens, long promptTokens, long totalTokens, IDictionary serializedAdditionalRawData) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunCompletionUsage() - { - } - - /// Number of completion tokens used over the course of the run. - public long CompletionTokens { get; } - /// Number of prompt tokens used over the course of the run. - public long PromptTokens { get; } - /// Total number of tokens used (prompt + completion). - public long TotalTokens { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunError.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunError.Serialization.cs deleted file mode 100644 index b4793137daef..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunError.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 RunError : 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(RunError)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code); - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - 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 - } - } - } - - RunError 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(RunError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunError(document.RootElement, options); - } - - internal static RunError DeserializeRunError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string code = default; - string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code"u8)) - { - code = property.Value.GetString(); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunError(code, message, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunError)} does not support writing '{options.Format}' format."); - } - } - - RunError 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 DeserializeRunError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunError)} 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 RunError FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunError(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/RunError.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunError.cs deleted file mode 100644 index 1593311d899a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunError.cs +++ /dev/null @@ -1,82 +0,0 @@ -// 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 details of an error as encountered by an agent thread run. - public partial class RunError - { - /// - /// 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 status for the error. - /// The human-readable text associated with the error. - /// or is null. - internal RunError(string code, string message) - { - Argument.AssertNotNull(code, nameof(code)); - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - } - - /// Initializes a new instance of . - /// The status for the error. - /// The human-readable text associated with the error. - /// Keeps track of any properties unknown to the library. - internal RunError(string code, string message, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunError() - { - } - - /// The status for the error. - public string Code { get; } - /// The human-readable text associated with the error. - public string Message { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStatus.cs deleted file mode 100644 index 4abba05c525d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStatus.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Possible values for the status of an agent thread run. - public readonly partial struct RunStatus : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RunStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string QueuedValue = "queued"; - private const string InProgressValue = "in_progress"; - private const string RequiresActionValue = "requires_action"; - private const string CancellingValue = "cancelling"; - private const string CancelledValue = "cancelled"; - private const string FailedValue = "failed"; - private const string CompletedValue = "completed"; - private const string ExpiredValue = "expired"; - - /// Represents a run that is queued to start. - public static RunStatus Queued { get; } = new RunStatus(QueuedValue); - /// Represents a run that is in progress. - public static RunStatus InProgress { get; } = new RunStatus(InProgressValue); - /// Represents a run that needs another operation, such as tool output submission, to continue. - public static RunStatus RequiresAction { get; } = new RunStatus(RequiresActionValue); - /// Represents a run that is in the process of cancellation. - public static RunStatus Cancelling { get; } = new RunStatus(CancellingValue); - /// Represents a run that has been cancelled. - public static RunStatus Cancelled { get; } = new RunStatus(CancelledValue); - /// Represents a run that failed. - public static RunStatus Failed { get; } = new RunStatus(FailedValue); - /// Represents a run that successfully completed. - public static RunStatus Completed { get; } = new RunStatus(CompletedValue); - /// Represents a run that expired before it could otherwise finish. - public static RunStatus Expired { get; } = new RunStatus(ExpiredValue); - /// Determines if two values are the same. - public static bool operator ==(RunStatus left, RunStatus right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RunStatus left, RunStatus right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator RunStatus(string value) => new RunStatus(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStatus other && Equals(other); - /// - public bool Equals(RunStatus 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/sdk/ai/Azure.AI.Projects/src/Generated/RunStep.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStep.Serialization.cs deleted file mode 100644 index c2ea2f1434f0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStep.Serialization.cs +++ /dev/null @@ -1,357 +0,0 @@ -// 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 RunStep : 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(RunStep)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); - writer.WritePropertyName("thread_id"u8); - writer.WriteStringValue(ThreadId); - writer.WritePropertyName("run_id"u8); - writer.WriteStringValue(RunId); - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); - writer.WritePropertyName("step_details"u8); - writer.WriteObjectValue(StepDetails, options); - if (LastError != null) - { - writer.WritePropertyName("last_error"u8); - writer.WriteObjectValue(LastError, options); - } - else - { - writer.WriteNull("last_error"); - } - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - if (ExpiredAt != null) - { - writer.WritePropertyName("expired_at"u8); - writer.WriteNumberValue(ExpiredAt.Value, "U"); - } - else - { - writer.WriteNull("expired_at"); - } - if (CompletedAt != null) - { - writer.WritePropertyName("completed_at"u8); - writer.WriteNumberValue(CompletedAt.Value, "U"); - } - else - { - writer.WriteNull("completed_at"); - } - if (CancelledAt != null) - { - writer.WritePropertyName("cancelled_at"u8); - writer.WriteNumberValue(CancelledAt.Value, "U"); - } - else - { - writer.WriteNull("cancelled_at"); - } - if (FailedAt != null) - { - writer.WritePropertyName("failed_at"u8); - writer.WriteNumberValue(FailedAt.Value, "U"); - } - else - { - writer.WriteNull("failed_at"); - } - if (Optional.IsDefined(Usage)) - { - if (Usage != null) - { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); - } - else - { - writer.WriteNull("usage"); - } - } - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - 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 - } - } - } - - RunStep 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(RunStep)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStep(document.RootElement, options); - } - - internal static RunStep DeserializeRunStep(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - string @object = default; - RunStepType type = default; - string assistantId = default; - string threadId = default; - string runId = default; - RunStepStatus status = default; - RunStepDetails stepDetails = default; - RunStepError lastError = default; - DateTimeOffset createdAt = default; - DateTimeOffset? expiredAt = default; - DateTimeOffset? completedAt = default; - DateTimeOffset? cancelledAt = default; - DateTimeOffset? failedAt = default; - RunStepCompletionUsage usage = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new RunStepType(property.Value.GetString()); - continue; - } - if (property.NameEquals("assistant_id"u8)) - { - assistantId = property.Value.GetString(); - continue; - } - if (property.NameEquals("thread_id"u8)) - { - threadId = property.Value.GetString(); - continue; - } - if (property.NameEquals("run_id"u8)) - { - runId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new RunStepStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("step_details"u8)) - { - stepDetails = RunStepDetails.DeserializeRunStepDetails(property.Value, options); - continue; - } - if (property.NameEquals("last_error"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastError = null; - continue; - } - lastError = RunStepError.DeserializeRunStepError(property.Value, options); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("expired_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref expiredAt); - continue; - } - if (property.NameEquals("completed_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref completedAt); - continue; - } - if (property.NameEquals("cancelled_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref cancelledAt); - continue; - } - if (property.NameEquals("failed_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref failedAt); - continue; - } - if (property.NameEquals("usage"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - usage = null; - continue; - } - usage = RunStepCompletionUsage.DeserializeRunStepCompletionUsage(property.Value, options); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStep( - id, - @object, - type, - assistantId, - threadId, - runId, - status, - stepDetails, - lastError, - createdAt, - expiredAt, - completedAt, - cancelledAt, - failedAt, - usage, - metadata, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStep)} does not support writing '{options.Format}' format."); - } - } - - RunStep 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 DeserializeRunStep(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStep)} 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 RunStep FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStep(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/RunStep.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStep.cs deleted file mode 100644 index 6d403877ed00..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStep.cs +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Detailed information about a single step of an agent thread run. - public partial class RunStep - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// The type of run step, which can be either message_creation or tool_calls. - /// The ID of the agent associated with the run step. - /// The ID of the thread that was run. - /// The ID of the run that this run step is a part of. - /// The status of this run step. - /// - /// The 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 . - /// - /// If applicable, information about the last error encountered by this run step. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The Unix timestamp, in seconds, representing when this item expired. - /// The Unix timestamp, in seconds, representing when this completed. - /// The Unix timestamp, in seconds, representing when this was cancelled. - /// The Unix timestamp, in seconds, representing when this failed. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// , , , or is null. - internal RunStep(string id, RunStepType type, string assistantId, string threadId, string runId, RunStepStatus status, RunStepDetails stepDetails, RunStepError lastError, DateTimeOffset createdAt, DateTimeOffset? expiredAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(assistantId, nameof(assistantId)); - Argument.AssertNotNull(threadId, nameof(threadId)); - Argument.AssertNotNull(runId, nameof(runId)); - Argument.AssertNotNull(stepDetails, nameof(stepDetails)); - - Id = id; - Type = type; - AssistantId = assistantId; - ThreadId = threadId; - RunId = runId; - Status = status; - StepDetails = stepDetails; - LastError = lastError; - CreatedAt = createdAt; - ExpiredAt = expiredAt; - CompletedAt = completedAt; - CancelledAt = cancelledAt; - FailedAt = failedAt; - Metadata = metadata; - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always 'thread.run.step'. - /// The type of run step, which can be either message_creation or tool_calls. - /// The ID of the agent associated with the run step. - /// The ID of the thread that was run. - /// The ID of the run that this run step is a part of. - /// The status of this run step. - /// - /// The 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 . - /// - /// If applicable, information about the last error encountered by this run step. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The Unix timestamp, in seconds, representing when this item expired. - /// The Unix timestamp, in seconds, representing when this completed. - /// The Unix timestamp, in seconds, representing when this was cancelled. - /// The Unix timestamp, in seconds, representing when this failed. - /// Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal RunStep(string id, string @object, RunStepType type, string assistantId, string threadId, string runId, RunStepStatus status, RunStepDetails stepDetails, RunStepError lastError, DateTimeOffset createdAt, DateTimeOffset? expiredAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, RunStepCompletionUsage usage, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - Type = type; - AssistantId = assistantId; - ThreadId = threadId; - RunId = runId; - Status = status; - StepDetails = stepDetails; - LastError = lastError; - CreatedAt = createdAt; - ExpiredAt = expiredAt; - CompletedAt = completedAt; - CancelledAt = cancelledAt; - FailedAt = failedAt; - Usage = usage; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStep() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - - /// The type of run step, which can be either message_creation or tool_calls. - public RunStepType Type { get; } - /// The ID of the agent associated with the run step. - public string AssistantId { get; } - /// The ID of the thread that was run. - public string ThreadId { get; } - /// The ID of the run that this run step is a part of. - public string RunId { get; } - /// The status of this run step. - public RunStepStatus Status { get; } - /// - /// The 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 . - /// - public RunStepDetails StepDetails { get; } - /// If applicable, information about the last error encountered by this run step. - public RunStepError LastError { get; } - /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } - /// The Unix timestamp, in seconds, representing when this item expired. - public DateTimeOffset? ExpiredAt { get; } - /// The Unix timestamp, in seconds, representing when this completed. - public DateTimeOffset? CompletedAt { get; } - /// The Unix timestamp, in seconds, representing when this was cancelled. - public DateTimeOffset? CancelledAt { get; } - /// The Unix timestamp, in seconds, representing when this failed. - public DateTimeOffset? FailedAt { get; } - /// Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - public RunStepCompletionUsage Usage { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepAzureAISearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepAzureAISearchToolCall.Serialization.cs deleted file mode 100644 index 9bd09b527137..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepAzureAISearchToolCall.Serialization.cs +++ /dev/null @@ -1,151 +0,0 @@ -// 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 RunStepAzureAISearchToolCall : 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(RunStepAzureAISearchToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("azure_ai_search"u8); - writer.WriteStartObject(); - foreach (var item in AzureAISearch) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - - RunStepAzureAISearchToolCall 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(RunStepAzureAISearchToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepAzureAISearchToolCall(document.RootElement, options); - } - - internal static RunStepAzureAISearchToolCall DeserializeRunStepAzureAISearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyDictionary azureAiSearch = default; - string type = default; - string id = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("azure_ai_search"u8)) - { - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - azureAiSearch = 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 RunStepAzureAISearchToolCall(type, id, serializedAdditionalRawData, azureAiSearch); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepAzureAISearchToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepAzureAISearchToolCall 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 DeserializeRunStepAzureAISearchToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepAzureAISearchToolCall)} 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 RunStepAzureAISearchToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepAzureAISearchToolCall(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/RunStepAzureAISearchToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepAzureAISearchToolCall.cs deleted file mode 100644 index 6b31eced4af0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepAzureAISearchToolCall.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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 Azure AI Search tool, issued by the model in evaluation of a defined tool, that represents - /// executed Azure AI search. - /// - public partial class RunStepAzureAISearchToolCall : 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 RunStepAzureAISearchToolCall(string id, IReadOnlyDictionary azureAISearch) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(azureAISearch, nameof(azureAISearch)); - - Type = "azure_ai_search"; - AzureAISearch = azureAISearch; - } - - /// 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 RunStepAzureAISearchToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary azureAISearch) : base(type, id, serializedAdditionalRawData) - { - AzureAISearch = azureAISearch; - } - - /// Initializes a new instance of for deserialization. - internal RunStepAzureAISearchToolCall() - { - } - - /// Reserved for future use. - public IReadOnlyDictionary AzureAISearch { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepBingGroundingToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepBingGroundingToolCall.Serialization.cs deleted file mode 100644 index c135ac0c5d00..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepBingGroundingToolCall.Serialization.cs +++ /dev/null @@ -1,151 +0,0 @@ -// 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 RunStepBingGroundingToolCall : 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(RunStepBingGroundingToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("bing_grounding"u8); - writer.WriteStartObject(); - foreach (var item in BingGrounding) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - - RunStepBingGroundingToolCall 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(RunStepBingGroundingToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepBingGroundingToolCall(document.RootElement, options); - } - - internal static RunStepBingGroundingToolCall DeserializeRunStepBingGroundingToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyDictionary bingGrounding = default; - string type = default; - string id = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("bing_grounding"u8)) - { - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - bingGrounding = 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 RunStepBingGroundingToolCall(type, id, serializedAdditionalRawData, bingGrounding); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepBingGroundingToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepBingGroundingToolCall 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 DeserializeRunStepBingGroundingToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepBingGroundingToolCall)} 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 RunStepBingGroundingToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepBingGroundingToolCall(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/RunStepBingGroundingToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepBingGroundingToolCall.cs deleted file mode 100644 index 4b3e0c055278..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepBingGroundingToolCall.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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 grounding tool, issued by the model in evaluation of a defined tool, that represents - /// executed search with bing grounding. - /// - public partial class RunStepBingGroundingToolCall : 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 RunStepBingGroundingToolCall(string id, IReadOnlyDictionary bingGrounding) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(bingGrounding, nameof(bingGrounding)); - - Type = "bing_grounding"; - BingGrounding = bingGrounding; - } - - /// 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 RunStepBingGroundingToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary bingGrounding) : base(type, id, serializedAdditionalRawData) - { - BingGrounding = bingGrounding; - } - - /// Initializes a new instance of for deserialization. - internal RunStepBingGroundingToolCall() - { - } - - /// Reserved for future use. - public IReadOnlyDictionary BingGrounding { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs deleted file mode 100644 index 05c270dd8077..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 RunStepCodeInterpreterImageOutput : 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(RunStepCodeInterpreterImageOutput)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("image"u8); - writer.WriteObjectValue(Image, options); - } - - RunStepCodeInterpreterImageOutput 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(RunStepCodeInterpreterImageOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCodeInterpreterImageOutput(document.RootElement, options); - } - - internal static RunStepCodeInterpreterImageOutput DeserializeRunStepCodeInterpreterImageOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepCodeInterpreterImageReference image = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("image"u8)) - { - image = RunStepCodeInterpreterImageReference.DeserializeRunStepCodeInterpreterImageReference(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 RunStepCodeInterpreterImageOutput(type, serializedAdditionalRawData, image); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageOutput)} does not support writing '{options.Format}' format."); - } - } - - RunStepCodeInterpreterImageOutput 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 DeserializeRunStepCodeInterpreterImageOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageOutput)} 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 RunStepCodeInterpreterImageOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepCodeInterpreterImageOutput(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/RunStepCodeInterpreterImageOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageOutput.cs deleted file mode 100644 index 1b78e4af0233..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageOutput.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 representation of an image output emitted by a code interpreter tool in response to a tool call by the model. - public partial class RunStepCodeInterpreterImageOutput : RunStepCodeInterpreterToolCallOutput - { - /// Initializes a new instance of . - /// Referential information for the image associated with this output. - /// is null. - internal RunStepCodeInterpreterImageOutput(RunStepCodeInterpreterImageReference image) - { - Argument.AssertNotNull(image, nameof(image)); - - Type = "image"; - Image = image; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// Referential information for the image associated with this output. - internal RunStepCodeInterpreterImageOutput(string type, IDictionary serializedAdditionalRawData, RunStepCodeInterpreterImageReference image) : base(type, serializedAdditionalRawData) - { - Image = image; - } - - /// Initializes a new instance of for deserialization. - internal RunStepCodeInterpreterImageOutput() - { - } - - /// Referential information for the image associated with this output. - public RunStepCodeInterpreterImageReference Image { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageReference.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageReference.cs deleted file mode 100644 index aaed08a5c03a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterImageReference.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// An image reference emitted by a code interpreter tool in response to a tool call by the model. - public partial class RunStepCodeInterpreterImageReference - { - /// - /// 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 ID of the file associated with this image. - /// is null. - internal RunStepCodeInterpreterImageReference(string fileId) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - } - - /// Initializes a new instance of . - /// The ID of the file associated with this image. - /// Keeps track of any properties unknown to the library. - internal RunStepCodeInterpreterImageReference(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepCodeInterpreterImageReference() - { - } - - /// The ID of the file associated with this image. - public string FileId { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs deleted file mode 100644 index 052765554b10..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 RunStepCodeInterpreterLogOutput : 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(RunStepCodeInterpreterLogOutput)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("logs"u8); - writer.WriteStringValue(Logs); - } - - RunStepCodeInterpreterLogOutput 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(RunStepCodeInterpreterLogOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCodeInterpreterLogOutput(document.RootElement, options); - } - - internal static RunStepCodeInterpreterLogOutput DeserializeRunStepCodeInterpreterLogOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string logs = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("logs"u8)) - { - logs = property.Value.GetString(); - 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 RunStepCodeInterpreterLogOutput(type, serializedAdditionalRawData, logs); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterLogOutput)} does not support writing '{options.Format}' format."); - } - } - - RunStepCodeInterpreterLogOutput 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 DeserializeRunStepCodeInterpreterLogOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterLogOutput)} 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 RunStepCodeInterpreterLogOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepCodeInterpreterLogOutput(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/RunStepCodeInterpreterLogOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterLogOutput.cs deleted file mode 100644 index 84a3a237427f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterLogOutput.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 representation of a log output emitted by a code interpreter tool in response to a tool call by the model. - public partial class RunStepCodeInterpreterLogOutput : RunStepCodeInterpreterToolCallOutput - { - /// Initializes a new instance of . - /// The serialized log output emitted by the code interpreter. - /// is null. - internal RunStepCodeInterpreterLogOutput(string logs) - { - Argument.AssertNotNull(logs, nameof(logs)); - - Type = "logs"; - Logs = logs; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The serialized log output emitted by the code interpreter. - internal RunStepCodeInterpreterLogOutput(string type, IDictionary serializedAdditionalRawData, string logs) : base(type, serializedAdditionalRawData) - { - Logs = logs; - } - - /// Initializes a new instance of for deserialization. - internal RunStepCodeInterpreterLogOutput() - { - } - - /// The serialized log output emitted by the code interpreter. - public string Logs { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs deleted file mode 100644 index 158ba2de9704..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs +++ /dev/null @@ -1,140 +0,0 @@ -// 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 RunStepCodeInterpreterToolCall : 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(RunStepCodeInterpreterToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(InternalDetails, options); - } - - RunStepCodeInterpreterToolCall 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(RunStepCodeInterpreterToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCodeInterpreterToolCall(document.RootElement, options); - } - - internal static RunStepCodeInterpreterToolCall DeserializeRunStepCodeInterpreterToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalCodeInterpreterToolCallDetails codeInterpreter = default; - string type = default; - string id = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code_interpreter"u8)) - { - codeInterpreter = InternalCodeInterpreterToolCallDetails.DeserializeInternalCodeInterpreterToolCallDetails(property.Value, options); - 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 RunStepCodeInterpreterToolCall(type, id, serializedAdditionalRawData, codeInterpreter); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepCodeInterpreterToolCall 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 DeserializeRunStepCodeInterpreterToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCall)} 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 RunStepCodeInterpreterToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepCodeInterpreterToolCall(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/RunStepCodeInterpreterToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCall.cs deleted file mode 100644 index 9c834e3d74d1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCall.cs +++ /dev/null @@ -1,47 +0,0 @@ -// 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 code interpreter tool, issued by the model in evaluation of a defined tool, that - /// represents inputs and outputs consumed and emitted by the code interpreter. - /// - public partial class RunStepCodeInterpreterToolCall : RunStepToolCall - { - /// Initializes a new instance of . - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// The details of the tool call to the code interpreter tool. - /// or is null. - internal RunStepCodeInterpreterToolCall(string id, InternalCodeInterpreterToolCallDetails internalDetails) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(internalDetails, nameof(internalDetails)); - - Type = "code_interpreter"; - InternalDetails = internalDetails; - } - - /// 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. - /// The details of the tool call to the code interpreter tool. - internal RunStepCodeInterpreterToolCall(string type, string id, IDictionary serializedAdditionalRawData, InternalCodeInterpreterToolCallDetails internalDetails) : base(type, id, serializedAdditionalRawData) - { - InternalDetails = internalDetails; - } - - /// Initializes a new instance of for deserialization. - internal RunStepCodeInterpreterToolCall() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs deleted file mode 100644 index 0aa97e0a916d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownRunStepCodeInterpreterToolCallOutput))] - public partial class RunStepCodeInterpreterToolCallOutput : 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(RunStepCodeInterpreterToolCallOutput)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - RunStepCodeInterpreterToolCallOutput 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(RunStepCodeInterpreterToolCallOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); - } - - internal static RunStepCodeInterpreterToolCallOutput DeserializeRunStepCodeInterpreterToolCallOutput(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 "image": return RunStepCodeInterpreterImageOutput.DeserializeRunStepCodeInterpreterImageOutput(element, options); - case "logs": return RunStepCodeInterpreterLogOutput.DeserializeRunStepCodeInterpreterLogOutput(element, options); - } - } - return UnknownRunStepCodeInterpreterToolCallOutput.DeserializeUnknownRunStepCodeInterpreterToolCallOutput(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support writing '{options.Format}' format."); - } - } - - RunStepCodeInterpreterToolCallOutput 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 DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} 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 RunStepCodeInterpreterToolCallOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepCodeInterpreterToolCallOutput(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/RunStepCodeInterpreterToolCallOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCallOutput.cs deleted file mode 100644 index 95cd5d808144..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCodeInterpreterToolCallOutput.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// An abstract representation of an emitted output from a code interpreter tool. - /// 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 RunStepCodeInterpreterToolCallOutput - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected RunStepCodeInterpreterToolCallOutput() - { - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal RunStepCodeInterpreterToolCallOutput(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The object type. - internal string Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCompletionUsage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCompletionUsage.Serialization.cs deleted file mode 100644 index 10aa385f8846..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCompletionUsage.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 RunStepCompletionUsage : 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(RunStepCompletionUsage)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("completion_tokens"u8); - writer.WriteNumberValue(CompletionTokens); - writer.WritePropertyName("prompt_tokens"u8); - writer.WriteNumberValue(PromptTokens); - writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokens); - 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 - } - } - } - - RunStepCompletionUsage 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(RunStepCompletionUsage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCompletionUsage(document.RootElement, options); - } - - internal static RunStepCompletionUsage DeserializeRunStepCompletionUsage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - long completionTokens = default; - long promptTokens = default; - long totalTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("completion_tokens"u8)) - { - completionTokens = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("prompt_tokens"u8)) - { - promptTokens = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("total_tokens"u8)) - { - totalTokens = property.Value.GetInt64(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepCompletionUsage(completionTokens, promptTokens, totalTokens, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support writing '{options.Format}' format."); - } - } - - RunStepCompletionUsage 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 DeserializeRunStepCompletionUsage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepCompletionUsage)} 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 RunStepCompletionUsage FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepCompletionUsage(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/RunStepCompletionUsage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCompletionUsage.cs deleted file mode 100644 index 6750fa1223c1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCompletionUsage.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Usage statistics related to the run step. - public partial class RunStepCompletionUsage - { - /// - /// 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 . - /// Number of completion tokens used over the course of the run step. - /// Number of prompt tokens used over the course of the run step. - /// Total number of tokens used (prompt + completion). - internal RunStepCompletionUsage(long completionTokens, long promptTokens, long totalTokens) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - } - - /// Initializes a new instance of . - /// Number of completion tokens used over the course of the run step. - /// Number of prompt tokens used over the course of the run step. - /// Total number of tokens used (prompt + completion). - /// Keeps track of any properties unknown to the library. - internal RunStepCompletionUsage(long completionTokens, long promptTokens, long totalTokens, IDictionary serializedAdditionalRawData) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepCompletionUsage() - { - } - - /// Number of completion tokens used over the course of the run step. - public long CompletionTokens { get; } - /// Number of prompt tokens used over the course of the run step. - public long PromptTokens { get; } - /// Total number of tokens used (prompt + completion). - public long TotalTokens { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.cs deleted file mode 100644 index dd6618679e2c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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/RunStepDelta.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDelta.Serialization.cs deleted file mode 100644 index 47fc3c68466c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDelta.Serialization.cs +++ /dev/null @@ -1,149 +0,0 @@ -// 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 RunStepDelta : 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(RunStepDelta)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(StepDetails)) - { - writer.WritePropertyName("step_details"u8); - writer.WriteObjectValue(StepDetails, options); - } - 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 - } - } - } - - RunStepDelta 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(RunStepDelta)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDelta(document.RootElement, options); - } - - internal static RunStepDelta DeserializeRunStepDelta(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepDeltaDetail stepDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("step_details"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - stepDetails = RunStepDeltaDetail.DeserializeRunStepDeltaDetail(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepDelta(stepDetails, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDelta)} does not support writing '{options.Format}' format."); - } - } - - RunStepDelta 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 DeserializeRunStepDelta(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDelta)} 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 RunStepDelta FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDelta(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/RunStepDelta.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDelta.cs deleted file mode 100644 index 0f601698841d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDelta.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents the delta payload in a streaming run step delta chunk. - public partial class RunStepDelta - { - /// - /// 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 . - internal RunStepDelta() - { - } - - /// Initializes a new instance of . - /// - /// The details of the 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 . - /// - /// Keeps track of any properties unknown to the library. - internal RunStepDelta(RunStepDeltaDetail stepDetails, IDictionary serializedAdditionalRawData) - { - StepDetails = stepDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// The details of the 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 . - /// - public RunStepDeltaDetail StepDetails { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaChunk.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaChunk.Serialization.cs deleted file mode 100644 index a00deff36c7b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaChunk.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 RunStepDeltaChunk : 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(RunStepDeltaChunk)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("delta"u8); - writer.WriteObjectValue(Delta, options); - 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 - } - } - } - - RunStepDeltaChunk 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(RunStepDeltaChunk)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaChunk(document.RootElement, options); - } - - internal static RunStepDeltaChunk DeserializeRunStepDeltaChunk(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - RunStepDeltaChunkObject @object = default; - RunStepDelta delta = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new RunStepDeltaChunkObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("delta"u8)) - { - delta = RunStepDelta.DeserializeRunStepDelta(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepDeltaChunk(id, @object, delta, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaChunk 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 DeserializeRunStepDeltaChunk(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaChunk)} 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 RunStepDeltaChunk FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaChunk(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/RunStepDeltaChunk.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaChunk.cs deleted file mode 100644 index bd48db51e72c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaChunk.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a run step delta i.e. any changed fields on a run step during streaming. - public partial class RunStepDeltaChunk - { - /// - /// 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 identifier of the run step, which can be referenced in API endpoints. - /// The delta containing the fields that have changed on the run step. - /// or is null. - internal RunStepDeltaChunk(string id, RunStepDelta delta) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(delta, nameof(delta)); - - Id = id; - Delta = delta; - } - - /// Initializes a new instance of . - /// The identifier of the run step, which can be referenced in API endpoints. - /// The object type, which is always `thread.run.step.delta`. - /// The delta containing the fields that have changed on the run step. - /// Keeps track of any properties unknown to the library. - internal RunStepDeltaChunk(string id, RunStepDeltaChunkObject @object, RunStepDelta delta, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - Delta = delta; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepDeltaChunk() - { - } - - /// The identifier of the run step, which can be referenced in API endpoints. - public string Id { get; } - /// The object type, which is always `thread.run.step.delta`. - public RunStepDeltaChunkObject Object { get; } = RunStepDeltaChunkObject.ThreadRunStepDelta; - - /// The delta containing the fields that have changed on the run step. - public RunStepDelta Delta { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaChunkObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaChunkObject.cs deleted file mode 100644 index 3f217f543661..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaChunkObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The RunStepDeltaChunk_object. - public readonly partial struct RunStepDeltaChunkObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RunStepDeltaChunkObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; - - /// thread.run.step.delta. - public static RunStepDeltaChunkObject ThreadRunStepDelta { get; } = new RunStepDeltaChunkObject(ThreadRunStepDeltaValue); - /// Determines if two values are the same. - public static bool operator ==(RunStepDeltaChunkObject left, RunStepDeltaChunkObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RunStepDeltaChunkObject left, RunStepDeltaChunkObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator RunStepDeltaChunkObject(string value) => new RunStepDeltaChunkObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepDeltaChunkObject other && Equals(other); - /// - public bool Equals(RunStepDeltaChunkObject 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/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs deleted file mode 100644 index 20ade7d8b53e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs +++ /dev/null @@ -1,170 +0,0 @@ -// 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 RunStepDeltaCodeInterpreterDetailItemObject : 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(RunStepDeltaCodeInterpreterDetailItemObject)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(Input)) - { - writer.WritePropertyName("input"u8); - writer.WriteStringValue(Input); - } - if (Optional.IsCollectionDefined(Outputs)) - { - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) - { - 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 - } - } - } - - RunStepDeltaCodeInterpreterDetailItemObject 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(RunStepDeltaCodeInterpreterDetailItemObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaCodeInterpreterDetailItemObject(document.RootElement, options); - } - - internal static RunStepDeltaCodeInterpreterDetailItemObject DeserializeRunStepDeltaCodeInterpreterDetailItemObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string input = default; - IReadOnlyList outputs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("input"u8)) - { - input = property.Value.GetString(); - continue; - } - if (property.NameEquals("outputs"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepDeltaCodeInterpreterOutput.DeserializeRunStepDeltaCodeInterpreterOutput(item, options)); - } - outputs = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepDeltaCodeInterpreterDetailItemObject(input, outputs ?? 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaCodeInterpreterDetailItemObject 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 DeserializeRunStepDeltaCodeInterpreterDetailItemObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} 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 RunStepDeltaCodeInterpreterDetailItemObject FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaCodeInterpreterDetailItemObject(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/RunStepDeltaCodeInterpreterDetailItemObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs deleted file mode 100644 index a76ab9ec7a09..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents the Code Interpreter tool call data in a streaming run step's tool calls. - public partial class RunStepDeltaCodeInterpreterDetailItemObject - { - /// - /// 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 . - internal RunStepDeltaCodeInterpreterDetailItemObject() - { - Outputs = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The input into the Code Interpreter tool call. - /// - /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more - /// items, including text (`logs`) or images (`image`). Each of these are represented by a - /// different object type. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal RunStepDeltaCodeInterpreterDetailItemObject(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) - { - Input = input; - Outputs = outputs; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The input into the Code Interpreter tool call. - public string Input { get; } - /// - /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more - /// items, including text (`logs`) or images (`image`). Each of these are represented by a - /// different object type. - /// 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 IReadOnlyList Outputs { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs deleted file mode 100644 index 62eadbd3dc01..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs +++ /dev/null @@ -1,147 +0,0 @@ -// 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 RunStepDeltaCodeInterpreterImageOutput : 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(RunStepDeltaCodeInterpreterImageOutput)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(Image)) - { - writer.WritePropertyName("image"u8); - writer.WriteObjectValue(Image, options); - } - } - - RunStepDeltaCodeInterpreterImageOutput 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(RunStepDeltaCodeInterpreterImageOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaCodeInterpreterImageOutput(document.RootElement, options); - } - - internal static RunStepDeltaCodeInterpreterImageOutput DeserializeRunStepDeltaCodeInterpreterImageOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepDeltaCodeInterpreterImageOutputObject image = default; - int index = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("image"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - image = RunStepDeltaCodeInterpreterImageOutputObject.DeserializeRunStepDeltaCodeInterpreterImageOutputObject(property.Value, options); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 RunStepDeltaCodeInterpreterImageOutput(index, type, serializedAdditionalRawData, image); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaCodeInterpreterImageOutput 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 DeserializeRunStepDeltaCodeInterpreterImageOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} 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 RunStepDeltaCodeInterpreterImageOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaCodeInterpreterImageOutput(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/RunStepDeltaCodeInterpreterImageOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs deleted file mode 100644 index de128c6b8688..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents an image output as produced the Code interpreter tool and as represented in a streaming run step's delta tool calls collection. - public partial class RunStepDeltaCodeInterpreterImageOutput : RunStepDeltaCodeInterpreterOutput - { - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - internal RunStepDeltaCodeInterpreterImageOutput(int index) : base(index) - { - Type = "image"; - } - - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - /// The type of the streaming run step tool call's Code Interpreter output. - /// Keeps track of any properties unknown to the library. - /// The image data for the Code Interpreter tool call output. - internal RunStepDeltaCodeInterpreterImageOutput(int index, string type, IDictionary serializedAdditionalRawData, RunStepDeltaCodeInterpreterImageOutputObject image) : base(index, type, serializedAdditionalRawData) - { - Image = image; - } - - /// Initializes a new instance of for deserialization. - internal RunStepDeltaCodeInterpreterImageOutput() - { - } - - /// The image data for the Code Interpreter tool call output. - public RunStepDeltaCodeInterpreterImageOutputObject Image { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs deleted file mode 100644 index 17d559cc07d3..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs +++ /dev/null @@ -1,145 +0,0 @@ -// 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 RunStepDeltaCodeInterpreterImageOutputObject : 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(RunStepDeltaCodeInterpreterImageOutputObject)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - 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 - } - } - } - - RunStepDeltaCodeInterpreterImageOutputObject 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(RunStepDeltaCodeInterpreterImageOutputObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaCodeInterpreterImageOutputObject(document.RootElement, options); - } - - internal static RunStepDeltaCodeInterpreterImageOutputObject DeserializeRunStepDeltaCodeInterpreterImageOutputObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepDeltaCodeInterpreterImageOutputObject(fileId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaCodeInterpreterImageOutputObject 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 DeserializeRunStepDeltaCodeInterpreterImageOutputObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} 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 RunStepDeltaCodeInterpreterImageOutputObject FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaCodeInterpreterImageOutputObject(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/RunStepDeltaCodeInterpreterImageOutputObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs deleted file mode 100644 index 8089067be9d7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents the data for a streaming run step's Code Interpreter tool call image output. - public partial class RunStepDeltaCodeInterpreterImageOutputObject - { - /// - /// 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 . - internal RunStepDeltaCodeInterpreterImageOutputObject() - { - } - - /// Initializes a new instance of . - /// The file ID for the image. - /// Keeps track of any properties unknown to the library. - internal RunStepDeltaCodeInterpreterImageOutputObject(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The file ID for the image. - public string FileId { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs deleted file mode 100644 index 2e1509b6fc6b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs +++ /dev/null @@ -1,143 +0,0 @@ -// 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 RunStepDeltaCodeInterpreterLogOutput : 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(RunStepDeltaCodeInterpreterLogOutput)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(Logs)) - { - writer.WritePropertyName("logs"u8); - writer.WriteStringValue(Logs); - } - } - - RunStepDeltaCodeInterpreterLogOutput 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(RunStepDeltaCodeInterpreterLogOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaCodeInterpreterLogOutput(document.RootElement, options); - } - - internal static RunStepDeltaCodeInterpreterLogOutput DeserializeRunStepDeltaCodeInterpreterLogOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string logs = default; - int index = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("logs"u8)) - { - logs = property.Value.GetString(); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 RunStepDeltaCodeInterpreterLogOutput(index, type, serializedAdditionalRawData, logs); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaCodeInterpreterLogOutput 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 DeserializeRunStepDeltaCodeInterpreterLogOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} 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 RunStepDeltaCodeInterpreterLogOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaCodeInterpreterLogOutput(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/RunStepDeltaCodeInterpreterLogOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs deleted file mode 100644 index 31f3284b073f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a log output as produced by the Code Interpreter tool and as represented in a streaming run step's delta tool calls collection. - public partial class RunStepDeltaCodeInterpreterLogOutput : RunStepDeltaCodeInterpreterOutput - { - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - internal RunStepDeltaCodeInterpreterLogOutput(int index) : base(index) - { - Type = "logs"; - } - - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - /// The type of the streaming run step tool call's Code Interpreter output. - /// Keeps track of any properties unknown to the library. - /// The text output from the Code Interpreter tool call. - internal RunStepDeltaCodeInterpreterLogOutput(int index, string type, IDictionary serializedAdditionalRawData, string logs) : base(index, type, serializedAdditionalRawData) - { - Logs = logs; - } - - /// Initializes a new instance of for deserialization. - internal RunStepDeltaCodeInterpreterLogOutput() - { - } - - /// The text output from the Code Interpreter tool call. - public string Logs { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs deleted file mode 100644 index 15e0a623c24f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownRunStepDeltaCodeInterpreterOutput))] - public partial class RunStepDeltaCodeInterpreterOutput : 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(RunStepDeltaCodeInterpreterOutput)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - RunStepDeltaCodeInterpreterOutput 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(RunStepDeltaCodeInterpreterOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); - } - - internal static RunStepDeltaCodeInterpreterOutput DeserializeRunStepDeltaCodeInterpreterOutput(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 "image": return RunStepDeltaCodeInterpreterImageOutput.DeserializeRunStepDeltaCodeInterpreterImageOutput(element, options); - case "logs": return RunStepDeltaCodeInterpreterLogOutput.DeserializeRunStepDeltaCodeInterpreterLogOutput(element, options); - } - } - return UnknownRunStepDeltaCodeInterpreterOutput.DeserializeUnknownRunStepDeltaCodeInterpreterOutput(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaCodeInterpreterOutput 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 DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} 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 RunStepDeltaCodeInterpreterOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaCodeInterpreterOutput(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/RunStepDeltaCodeInterpreterOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterOutput.cs deleted file mode 100644 index 656ea7ded2c3..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterOutput.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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 abstract base representation of a streaming run step tool call's Code Interpreter tool output. - /// 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 RunStepDeltaCodeInterpreterOutput - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - protected RunStepDeltaCodeInterpreterOutput(int index) - { - Index = index; - } - - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - /// The type of the streaming run step tool call's Code Interpreter output. - /// Keeps track of any properties unknown to the library. - internal RunStepDeltaCodeInterpreterOutput(int index, string type, IDictionary serializedAdditionalRawData) - { - Index = index; - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepDeltaCodeInterpreterOutput() - { - } - - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - public int Index { get; } - /// The type of the streaming run step tool call's Code Interpreter output. - internal string Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs deleted file mode 100644 index 74be7a30473c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs +++ /dev/null @@ -1,153 +0,0 @@ -// 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 RunStepDeltaCodeInterpreterToolCall : 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(RunStepDeltaCodeInterpreterToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - } - - RunStepDeltaCodeInterpreterToolCall 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(RunStepDeltaCodeInterpreterToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaCodeInterpreterToolCall(document.RootElement, options); - } - - internal static RunStepDeltaCodeInterpreterToolCall DeserializeRunStepDeltaCodeInterpreterToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = default; - int index = default; - string id = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code_interpreter"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = RunStepDeltaCodeInterpreterDetailItemObject.DeserializeRunStepDeltaCodeInterpreterDetailItemObject(property.Value, options); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - 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 RunStepDeltaCodeInterpreterToolCall(index, id, type, serializedAdditionalRawData, codeInterpreter); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaCodeInterpreterToolCall 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 DeserializeRunStepDeltaCodeInterpreterToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} 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 RunStepDeltaCodeInterpreterToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaCodeInterpreterToolCall(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/RunStepDeltaCodeInterpreterToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs deleted file mode 100644 index 8483fa22d47f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a Code Interpreter tool call within a streaming run step's tool call details. - public partial class RunStepDeltaCodeInterpreterToolCall : RunStepDeltaToolCall - { - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// is null. - internal RunStepDeltaCodeInterpreterToolCall(int index, string id) : base(index, id) - { - Argument.AssertNotNull(id, nameof(id)); - - Type = "code_interpreter"; - } - - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// The type of the tool call detail item in a streaming run step's details. - /// Keeps track of any properties unknown to the library. - /// The Code Interpreter data for the tool call. - internal RunStepDeltaCodeInterpreterToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter) : base(index, id, type, serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - } - - /// Initializes a new instance of for deserialization. - internal RunStepDeltaCodeInterpreterToolCall() - { - } - - /// The Code Interpreter data for the tool call. - public RunStepDeltaCodeInterpreterDetailItemObject CodeInterpreter { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaDetail.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaDetail.Serialization.cs deleted file mode 100644 index aab82f3f0266..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaDetail.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownRunStepDeltaDetail))] - public partial class RunStepDeltaDetail : 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(RunStepDeltaDetail)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - RunStepDeltaDetail 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(RunStepDeltaDetail)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaDetail(document.RootElement, options); - } - - internal static RunStepDeltaDetail DeserializeRunStepDeltaDetail(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 "message_creation": return RunStepDeltaMessageCreation.DeserializeRunStepDeltaMessageCreation(element, options); - case "tool_calls": return RunStepDeltaToolCallObject.DeserializeRunStepDeltaToolCallObject(element, options); - } - } - return UnknownRunStepDeltaDetail.DeserializeUnknownRunStepDeltaDetail(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaDetail 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 DeserializeRunStepDeltaDetail(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaDetail)} 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 RunStepDeltaDetail FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaDetail(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/RunStepDeltaDetail.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaDetail.cs deleted file mode 100644 index 68de601fb537..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaDetail.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// Represents a single run step detail item in a streaming run step's delta payload. - /// 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 RunStepDeltaDetail - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected RunStepDeltaDetail() - { - } - - /// Initializes a new instance of . - /// The object type for the run step detail object. - /// Keeps track of any properties unknown to the library. - internal RunStepDeltaDetail(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The object type for the run step detail object. - internal string Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs deleted file mode 100644 index 3da3795a7181..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs +++ /dev/null @@ -1,153 +0,0 @@ -// 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 RunStepDeltaFileSearchToolCall : 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(RunStepDeltaFileSearchToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - } - - RunStepDeltaFileSearchToolCall 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(RunStepDeltaFileSearchToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaFileSearchToolCall(document.RootElement, options); - } - - internal static RunStepDeltaFileSearchToolCall DeserializeRunStepDeltaFileSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepFileSearchToolCallResults fileSearch = default; - int index = default; - string id = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_search"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = RunStepFileSearchToolCallResults.DeserializeRunStepFileSearchToolCallResults(property.Value, options); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - 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 RunStepDeltaFileSearchToolCall(index, id, type, serializedAdditionalRawData, fileSearch); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaFileSearchToolCall 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 DeserializeRunStepDeltaFileSearchToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} 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 RunStepDeltaFileSearchToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaFileSearchToolCall(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/RunStepDeltaFileSearchToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFileSearchToolCall.cs deleted file mode 100644 index 4c39bc5e2ad2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFileSearchToolCall.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a file search tool call within a streaming run step's tool call details. - public partial class RunStepDeltaFileSearchToolCall : RunStepDeltaToolCall - { - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// is null. - internal RunStepDeltaFileSearchToolCall(int index, string id) : base(index, id) - { - Argument.AssertNotNull(id, nameof(id)); - - Type = "file_search"; - } - - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// The type of the tool call detail item in a streaming run step's details. - /// Keeps track of any properties unknown to the library. - /// Reserved for future use. - internal RunStepDeltaFileSearchToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, RunStepFileSearchToolCallResults fileSearch) : base(index, id, type, serializedAdditionalRawData) - { - FileSearch = fileSearch; - } - - /// Initializes a new instance of for deserialization. - internal RunStepDeltaFileSearchToolCall() - { - } - - /// Reserved for future use. - public RunStepFileSearchToolCallResults FileSearch { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunction.cs deleted file mode 100644 index 70f21095badd..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunction.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents the function data in a streaming run step delta's function tool call. - public partial class RunStepDeltaFunction - { - /// - /// 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 . - internal RunStepDeltaFunction() - { - } - - /// Initializes a new instance of . - /// The name of the function. - /// The arguments passed to the function as input. - /// The output of the function, null if outputs have not yet been submitted. - /// Keeps track of any properties unknown to the library. - internal RunStepDeltaFunction(string name, string arguments, string output, IDictionary serializedAdditionalRawData) - { - Name = name; - Arguments = arguments; - Output = output; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The name of the function. - public string Name { get; } - /// The arguments passed to the function as input. - public string Arguments { get; } - /// The output of the function, null if outputs have not yet been submitted. - public string Output { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs deleted file mode 100644 index a908624e31b7..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs +++ /dev/null @@ -1,153 +0,0 @@ -// 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 RunStepDeltaFunctionToolCall : 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(RunStepDeltaFunctionToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(Function)) - { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(Function, options); - } - } - - RunStepDeltaFunctionToolCall 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(RunStepDeltaFunctionToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaFunctionToolCall(document.RootElement, options); - } - - internal static RunStepDeltaFunctionToolCall DeserializeRunStepDeltaFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepDeltaFunction function = default; - int index = default; - string id = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("function"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - function = RunStepDeltaFunction.DeserializeRunStepDeltaFunction(property.Value, options); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - 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 RunStepDeltaFunctionToolCall(index, id, type, serializedAdditionalRawData, function); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaFunctionToolCall 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 DeserializeRunStepDeltaFunctionToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} 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 RunStepDeltaFunctionToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaFunctionToolCall(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/RunStepDeltaFunctionToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunctionToolCall.cs deleted file mode 100644 index 1347a2ce39bf..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFunctionToolCall.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a function tool call within a streaming run step's tool call details. - public partial class RunStepDeltaFunctionToolCall : RunStepDeltaToolCall - { - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// is null. - internal RunStepDeltaFunctionToolCall(int index, string id) : base(index, id) - { - Argument.AssertNotNull(id, nameof(id)); - - Type = "function"; - } - - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// The type of the tool call detail item in a streaming run step's details. - /// Keeps track of any properties unknown to the library. - /// The function data for the tool call. - internal RunStepDeltaFunctionToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, RunStepDeltaFunction function) : base(index, id, type, serializedAdditionalRawData) - { - Function = function; - } - - /// Initializes a new instance of for deserialization. - internal RunStepDeltaFunctionToolCall() - { - } - - /// The function data for the tool call. - public RunStepDeltaFunction Function { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreation.Serialization.cs deleted file mode 100644 index e848a25bc84a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreation.Serialization.cs +++ /dev/null @@ -1,141 +0,0 @@ -// 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 RunStepDeltaMessageCreation : 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(RunStepDeltaMessageCreation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsDefined(MessageCreation)) - { - writer.WritePropertyName("message_creation"u8); - writer.WriteObjectValue(MessageCreation, options); - } - } - - RunStepDeltaMessageCreation 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(RunStepDeltaMessageCreation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaMessageCreation(document.RootElement, options); - } - - internal static RunStepDeltaMessageCreation DeserializeRunStepDeltaMessageCreation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepDeltaMessageCreationObject messageCreation = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("message_creation"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - messageCreation = RunStepDeltaMessageCreationObject.DeserializeRunStepDeltaMessageCreationObject(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 RunStepDeltaMessageCreation(type, serializedAdditionalRawData, messageCreation); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaMessageCreation 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 DeserializeRunStepDeltaMessageCreation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} 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 RunStepDeltaMessageCreation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaMessageCreation(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/RunStepDeltaMessageCreation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreation.cs deleted file mode 100644 index c455f5326917..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreation.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents a message creation within a streaming run step delta. - public partial class RunStepDeltaMessageCreation : RunStepDeltaDetail - { - /// Initializes a new instance of . - internal RunStepDeltaMessageCreation() - { - Type = "message_creation"; - } - - /// Initializes a new instance of . - /// The object type for the run step detail object. - /// Keeps track of any properties unknown to the library. - /// The message creation data. - internal RunStepDeltaMessageCreation(string type, IDictionary serializedAdditionalRawData, RunStepDeltaMessageCreationObject messageCreation) : base(type, serializedAdditionalRawData) - { - MessageCreation = messageCreation; - } - - /// The message creation data. - public RunStepDeltaMessageCreationObject MessageCreation { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs deleted file mode 100644 index e2b154e72e27..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs +++ /dev/null @@ -1,145 +0,0 @@ -// 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 RunStepDeltaMessageCreationObject : 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(RunStepDeltaMessageCreationObject)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(MessageId)) - { - writer.WritePropertyName("message_id"u8); - writer.WriteStringValue(MessageId); - } - 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 - } - } - } - - RunStepDeltaMessageCreationObject 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(RunStepDeltaMessageCreationObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaMessageCreationObject(document.RootElement, options); - } - - internal static RunStepDeltaMessageCreationObject DeserializeRunStepDeltaMessageCreationObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string messageId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("message_id"u8)) - { - messageId = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepDeltaMessageCreationObject(messageId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaMessageCreationObject 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 DeserializeRunStepDeltaMessageCreationObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} 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 RunStepDeltaMessageCreationObject FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaMessageCreationObject(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/RunStepDeltaToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCall.Serialization.cs deleted file mode 100644 index 0b20189a7043..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCall.Serialization.cs +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownRunStepDeltaToolCall))] - public partial class RunStepDeltaToolCall : 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(RunStepDeltaToolCall)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - RunStepDeltaToolCall 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(RunStepDeltaToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaToolCall(document.RootElement, options); - } - - internal static RunStepDeltaToolCall DeserializeRunStepDeltaToolCall(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 "code_interpreter": return RunStepDeltaCodeInterpreterToolCall.DeserializeRunStepDeltaCodeInterpreterToolCall(element, options); - case "file_search": return RunStepDeltaFileSearchToolCall.DeserializeRunStepDeltaFileSearchToolCall(element, options); - case "function": return RunStepDeltaFunctionToolCall.DeserializeRunStepDeltaFunctionToolCall(element, options); - } - } - return UnknownRunStepDeltaToolCall.DeserializeUnknownRunStepDeltaToolCall(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaToolCall 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 DeserializeRunStepDeltaToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} 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 RunStepDeltaToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaToolCall(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/RunStepDeltaToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCall.cs deleted file mode 100644 index 198aae90f407..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCall.cs +++ /dev/null @@ -1,89 +0,0 @@ -// 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 abstract base representation of a single tool call within a streaming run step's delta tool call details. - /// 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 RunStepDeltaToolCall - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// is null. - protected RunStepDeltaToolCall(int index, string id) - { - Argument.AssertNotNull(id, nameof(id)); - - Index = index; - Id = id; - } - - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// The type of the tool call detail item in a streaming run step's details. - /// Keeps track of any properties unknown to the library. - internal RunStepDeltaToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData) - { - Index = index; - Id = id; - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepDeltaToolCall() - { - } - - /// The index of the tool call detail in the run step's tool_calls array. - public int Index { get; } - /// The ID of the tool call, used when submitting outputs to the run. - public string Id { get; } - /// The type of the tool call detail item in a streaming run step's details. - internal string Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCallObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCallObject.Serialization.cs deleted file mode 100644 index e167d377b574..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCallObject.Serialization.cs +++ /dev/null @@ -1,151 +0,0 @@ -// 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 RunStepDeltaToolCallObject : 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(RunStepDeltaToolCallObject)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (Optional.IsCollectionDefined(ToolCalls)) - { - writer.WritePropertyName("tool_calls"u8); - writer.WriteStartArray(); - foreach (var item in ToolCalls) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - } - - RunStepDeltaToolCallObject 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(RunStepDeltaToolCallObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaToolCallObject(document.RootElement, options); - } - - internal static RunStepDeltaToolCallObject DeserializeRunStepDeltaToolCallObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList toolCalls = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("tool_calls"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepDeltaToolCall.DeserializeRunStepDeltaToolCall(item, options)); - } - toolCalls = array; - 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 RunStepDeltaToolCallObject(type, serializedAdditionalRawData, toolCalls ?? new ChangeTrackingList()); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaToolCallObject 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 DeserializeRunStepDeltaToolCallObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} 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 RunStepDeltaToolCallObject FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepDeltaToolCallObject(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/RunStepDeltaToolCallObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCallObject.cs deleted file mode 100644 index 5778fcda8a0b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaToolCallObject.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Represents an invocation of tool calls as part of a streaming run step. - public partial class RunStepDeltaToolCallObject : RunStepDeltaDetail - { - /// Initializes a new instance of . - internal RunStepDeltaToolCallObject() - { - Type = "tool_calls"; - ToolCalls = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The object type for the run step detail object. - /// Keeps track of any properties unknown to the library. - /// - /// The collection of tool calls for the tool call detail item. - /// 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 . - /// - internal RunStepDeltaToolCallObject(string type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) - { - ToolCalls = toolCalls; - } - - /// - /// The collection of tool calls for the tool call detail item. - /// 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 IReadOnlyList ToolCalls { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDetails.cs deleted file mode 100644 index 872475195344..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDetails.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// An abstract representation of the details for a 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 . - /// - public abstract partial class RunStepDetails - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected RunStepDetails() - { - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal RunStepDetails(RunStepType type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The object type. - internal RunStepType Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepError.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepError.Serialization.cs deleted file mode 100644 index 447126838892..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepError.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 RunStepError : 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(RunStepError)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code.ToString()); - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - 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 - } - } - } - - RunStepError 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(RunStepError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepError(document.RootElement, options); - } - - internal static RunStepError DeserializeRunStepError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepErrorCode code = default; - string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code"u8)) - { - code = new RunStepErrorCode(property.Value.GetString()); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepError(code, message, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepError)} does not support writing '{options.Format}' format."); - } - } - - RunStepError 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 DeserializeRunStepError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepError)} 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 RunStepError FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepError(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/RunStepError.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepError.cs deleted file mode 100644 index 0980299543a5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepError.cs +++ /dev/null @@ -1,81 +0,0 @@ -// 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 error information associated with a failed run step. - public partial class RunStepError - { - /// - /// 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 error code for this error. - /// The human-readable text associated with this error. - /// is null. - internal RunStepError(RunStepErrorCode code, string message) - { - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - } - - /// Initializes a new instance of . - /// The error code for this error. - /// The human-readable text associated with this error. - /// Keeps track of any properties unknown to the library. - internal RunStepError(RunStepErrorCode code, string message, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepError() - { - } - - /// The error code for this error. - public RunStepErrorCode Code { get; } - /// The human-readable text associated with this error. - public string Message { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepErrorCode.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepErrorCode.cs deleted file mode 100644 index fc048aa38575..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepErrorCode.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Possible error code values attributable to a failed run step. - public readonly partial struct RunStepErrorCode : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RunStepErrorCode(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ServerErrorValue = "server_error"; - private const string RateLimitExceededValue = "rate_limit_exceeded"; - - /// Represents a server error. - public static RunStepErrorCode ServerError { get; } = new RunStepErrorCode(ServerErrorValue); - /// Represents an error indicating configured rate limits were exceeded. - public static RunStepErrorCode RateLimitExceeded { get; } = new RunStepErrorCode(RateLimitExceededValue); - /// Determines if two values are the same. - public static bool operator ==(RunStepErrorCode left, RunStepErrorCode right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RunStepErrorCode left, RunStepErrorCode right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator RunStepErrorCode(string value) => new RunStepErrorCode(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepErrorCode other && Equals(other); - /// - public bool Equals(RunStepErrorCode 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/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCall.Serialization.cs deleted file mode 100644 index 102022779eac..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCall.Serialization.cs +++ /dev/null @@ -1,140 +0,0 @@ -// 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 RunStepFileSearchToolCall : 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(RunStepFileSearchToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - - RunStepFileSearchToolCall 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(RunStepFileSearchToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepFileSearchToolCall(document.RootElement, options); - } - - internal static RunStepFileSearchToolCall DeserializeRunStepFileSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepFileSearchToolCallResults fileSearch = default; - string type = default; - string id = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_search"u8)) - { - fileSearch = RunStepFileSearchToolCallResults.DeserializeRunStepFileSearchToolCallResults(property.Value, options); - 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 RunStepFileSearchToolCall(type, id, serializedAdditionalRawData, fileSearch); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepFileSearchToolCall 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 DeserializeRunStepFileSearchToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} 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 RunStepFileSearchToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepFileSearchToolCall(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/RunStepFileSearchToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCall.cs deleted file mode 100644 index aec381fb6c39..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCall.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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 file search tool, issued by the model in evaluation of a defined tool, that represents - /// executed file search. - /// - public partial class RunStepFileSearchToolCall : RunStepToolCall - { - /// Initializes a new instance of . - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// For now, this is always going to be an empty object. - /// or is null. - internal RunStepFileSearchToolCall(string id, RunStepFileSearchToolCallResults fileSearch) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(fileSearch, nameof(fileSearch)); - - Type = "file_search"; - FileSearch = fileSearch; - } - - /// 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. - /// For now, this is always going to be an empty object. - internal RunStepFileSearchToolCall(string type, string id, IDictionary serializedAdditionalRawData, RunStepFileSearchToolCallResults fileSearch) : base(type, id, serializedAdditionalRawData) - { - FileSearch = fileSearch; - } - - /// Initializes a new instance of for deserialization. - internal RunStepFileSearchToolCall() - { - } - - /// For now, this is always going to be an empty object. - public RunStepFileSearchToolCallResults FileSearch { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResult.Serialization.cs deleted file mode 100644 index 0e46863ab92b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResult.Serialization.cs +++ /dev/null @@ -1,183 +0,0 @@ -// 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 RunStepFileSearchToolCallResult : 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(RunStepFileSearchToolCallResult)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - writer.WritePropertyName("file_name"u8); - writer.WriteStringValue(FileName); - writer.WritePropertyName("score"u8); - writer.WriteNumberValue(Score); - if (Optional.IsCollectionDefined(Content)) - { - writer.WritePropertyName("content"u8); - writer.WriteStartArray(); - foreach (var item in Content) - { - 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 - } - } - } - - RunStepFileSearchToolCallResult 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(RunStepFileSearchToolCallResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepFileSearchToolCallResult(document.RootElement, options); - } - - internal static RunStepFileSearchToolCallResult DeserializeRunStepFileSearchToolCallResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - string fileName = default; - float score = default; - IReadOnlyList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("file_name"u8)) - { - fileName = property.Value.GetString(); - continue; - } - if (property.NameEquals("score"u8)) - { - score = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("content"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(FileSearchToolCallContent.DeserializeFileSearchToolCallContent(item, options)); - } - content = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepFileSearchToolCallResult(fileId, fileName, score, content ?? 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResult)} does not support writing '{options.Format}' format."); - } - } - - RunStepFileSearchToolCallResult 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 DeserializeRunStepFileSearchToolCallResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResult)} 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 RunStepFileSearchToolCallResult FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepFileSearchToolCallResult(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/RunStepFileSearchToolCallResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResult.cs deleted file mode 100644 index fd13ac0486e5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResult.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// File search tool call result. - public partial class RunStepFileSearchToolCallResult - { - /// - /// 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 ID of the file that result was found in. - /// The name of the file that result was found in. - /// The score of the result. All values must be a floating point number between 0 and 1. - /// or is null. - internal RunStepFileSearchToolCallResult(string fileId, string fileName, float score) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - Argument.AssertNotNull(fileName, nameof(fileName)); - - FileId = fileId; - FileName = fileName; - Score = score; - Content = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The ID of the file that result was found in. - /// The name of the file that result was found in. - /// The score of the result. All values must be a floating point number between 0 and 1. - /// The content of the result that was found. The content is only included if requested via the include query parameter. - /// Keeps track of any properties unknown to the library. - internal RunStepFileSearchToolCallResult(string fileId, string fileName, float score, IReadOnlyList content, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - FileName = fileName; - Score = score; - Content = content; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepFileSearchToolCallResult() - { - } - - /// The ID of the file that result was found in. - public string FileId { get; } - /// The name of the file that result was found in. - public string FileName { get; } - /// The score of the result. All values must be a floating point number between 0 and 1. - public float Score { get; } - /// The content of the result that was found. The content is only included if requested via the include query parameter. - public IReadOnlyList Content { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResults.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResults.Serialization.cs deleted file mode 100644 index 88b1146b1aae..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResults.Serialization.cs +++ /dev/null @@ -1,167 +0,0 @@ -// 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 RunStepFileSearchToolCallResults : 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(RunStepFileSearchToolCallResults)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(RankingOptions)) - { - writer.WritePropertyName("ranking_options"u8); - writer.WriteObjectValue(RankingOptions, options); - } - writer.WritePropertyName("results"u8); - writer.WriteStartArray(); - foreach (var item in Results) - { - 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 - } - } - } - - RunStepFileSearchToolCallResults 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(RunStepFileSearchToolCallResults)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepFileSearchToolCallResults(document.RootElement, options); - } - - internal static RunStepFileSearchToolCallResults DeserializeRunStepFileSearchToolCallResults(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - FileSearchRankingOptions rankingOptions = default; - IReadOnlyList results = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("ranking_options"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(property.Value, options); - continue; - } - if (property.NameEquals("results"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepFileSearchToolCallResult.DeserializeRunStepFileSearchToolCallResult(item, options)); - } - results = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepFileSearchToolCallResults(rankingOptions, results, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResults)} does not support writing '{options.Format}' format."); - } - } - - RunStepFileSearchToolCallResults 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 DeserializeRunStepFileSearchToolCallResults(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResults)} 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 RunStepFileSearchToolCallResults FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepFileSearchToolCallResults(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/RunStepFileSearchToolCallResults.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResults.cs deleted file mode 100644 index 087a283ebaea..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFileSearchToolCallResults.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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 -{ - /// The results of the file search. - public partial class RunStepFileSearchToolCallResults - { - /// - /// 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 array of a file search results. - /// is null. - internal RunStepFileSearchToolCallResults(IEnumerable results) - { - Argument.AssertNotNull(results, nameof(results)); - - Results = results.ToList(); - } - - /// Initializes a new instance of . - /// Ranking options for file search. - /// The array of a file search results. - /// Keeps track of any properties unknown to the library. - internal RunStepFileSearchToolCallResults(FileSearchRankingOptions rankingOptions, IReadOnlyList results, IDictionary serializedAdditionalRawData) - { - RankingOptions = rankingOptions; - Results = results; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepFileSearchToolCallResults() - { - } - - /// Ranking options for file search. - public FileSearchRankingOptions RankingOptions { get; } - /// The array of a file search results. - public IReadOnlyList Results { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFunctionToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFunctionToolCall.Serialization.cs deleted file mode 100644 index 4b06c589959e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFunctionToolCall.Serialization.cs +++ /dev/null @@ -1,140 +0,0 @@ -// 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 RunStepFunctionToolCall : 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(RunStepFunctionToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(InternalDetails, options); - } - - RunStepFunctionToolCall 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(RunStepFunctionToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepFunctionToolCall(document.RootElement, options); - } - - internal static RunStepFunctionToolCall DeserializeRunStepFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalRunStepFunctionToolCallDetails function = default; - string type = default; - string id = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("function"u8)) - { - function = InternalRunStepFunctionToolCallDetails.DeserializeInternalRunStepFunctionToolCallDetails(property.Value, options); - 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 RunStepFunctionToolCall(type, id, serializedAdditionalRawData, function); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepFunctionToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepFunctionToolCall 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 DeserializeRunStepFunctionToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepFunctionToolCall)} 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 RunStepFunctionToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepFunctionToolCall(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/RunStepFunctionToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFunctionToolCall.cs deleted file mode 100644 index 7791557ae4a2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepFunctionToolCall.cs +++ /dev/null @@ -1,47 +0,0 @@ -// 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 function tool, issued by the model in evaluation of a defined tool, that represents the inputs - /// and output consumed and emitted by the specified function. - /// - public partial class RunStepFunctionToolCall : RunStepToolCall - { - /// Initializes a new instance of . - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// The detailed information about the function called by the model. - /// or is null. - internal RunStepFunctionToolCall(string id, InternalRunStepFunctionToolCallDetails internalDetails) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(internalDetails, nameof(internalDetails)); - - Type = "function"; - InternalDetails = internalDetails; - } - - /// 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. - /// The detailed information about the function called by the model. - internal RunStepFunctionToolCall(string type, string id, IDictionary serializedAdditionalRawData, InternalRunStepFunctionToolCallDetails internalDetails) : base(type, id, serializedAdditionalRawData) - { - InternalDetails = internalDetails; - } - - /// Initializes a new instance of for deserialization. - internal RunStepFunctionToolCall() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationDetails.Serialization.cs deleted file mode 100644 index 6d7507fc139d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationDetails.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 RunStepMessageCreationDetails : 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(RunStepMessageCreationDetails)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("message_creation"u8); - writer.WriteObjectValue(MessageCreation, options); - } - - RunStepMessageCreationDetails 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(RunStepMessageCreationDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepMessageCreationDetails(document.RootElement, options); - } - - internal static RunStepMessageCreationDetails DeserializeRunStepMessageCreationDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepMessageCreationReference messageCreation = default; - RunStepType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("message_creation"u8)) - { - messageCreation = RunStepMessageCreationReference.DeserializeRunStepMessageCreationReference(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new RunStepType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepMessageCreationDetails(type, serializedAdditionalRawData, messageCreation); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepMessageCreationDetails)} does not support writing '{options.Format}' format."); - } - } - - RunStepMessageCreationDetails 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 DeserializeRunStepMessageCreationDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepMessageCreationDetails)} 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 RunStepMessageCreationDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepMessageCreationDetails(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/RunStepMessageCreationDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationDetails.cs deleted file mode 100644 index ded89f984e4e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationDetails.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 detailed information associated with a message creation run step. - public partial class RunStepMessageCreationDetails : RunStepDetails - { - /// Initializes a new instance of . - /// Information about the message creation associated with this run step. - /// is null. - internal RunStepMessageCreationDetails(RunStepMessageCreationReference messageCreation) - { - Argument.AssertNotNull(messageCreation, nameof(messageCreation)); - - Type = RunStepType.MessageCreation; - MessageCreation = messageCreation; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// Information about the message creation associated with this run step. - internal RunStepMessageCreationDetails(RunStepType type, IDictionary serializedAdditionalRawData, RunStepMessageCreationReference messageCreation) : base(type, serializedAdditionalRawData) - { - MessageCreation = messageCreation; - } - - /// Initializes a new instance of for deserialization. - internal RunStepMessageCreationDetails() - { - } - - /// Information about the message creation associated with this run step. - public RunStepMessageCreationReference MessageCreation { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationReference.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationReference.Serialization.cs deleted file mode 100644 index 2db25392ca03..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationReference.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 RunStepMessageCreationReference : 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(RunStepMessageCreationReference)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("message_id"u8); - writer.WriteStringValue(MessageId); - 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 - } - } - } - - RunStepMessageCreationReference 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(RunStepMessageCreationReference)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepMessageCreationReference(document.RootElement, options); - } - - internal static RunStepMessageCreationReference DeserializeRunStepMessageCreationReference(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string messageId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("message_id"u8)) - { - messageId = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepMessageCreationReference(messageId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepMessageCreationReference)} does not support writing '{options.Format}' format."); - } - } - - RunStepMessageCreationReference 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 DeserializeRunStepMessageCreationReference(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepMessageCreationReference)} 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 RunStepMessageCreationReference FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepMessageCreationReference(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/RunStepMessageCreationReference.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationReference.cs deleted file mode 100644 index dbedc9a28ab6..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMessageCreationReference.cs +++ /dev/null @@ -1,75 +0,0 @@ -// 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 details of a message created as a part of a run step. - public partial class RunStepMessageCreationReference - { - /// - /// 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 ID of the message created by this run step. - /// is null. - internal RunStepMessageCreationReference(string messageId) - { - Argument.AssertNotNull(messageId, nameof(messageId)); - - MessageId = messageId; - } - - /// Initializes a new instance of . - /// The ID of the message created by this run step. - /// Keeps track of any properties unknown to the library. - internal RunStepMessageCreationReference(string messageId, IDictionary serializedAdditionalRawData) - { - MessageId = messageId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepMessageCreationReference() - { - } - - /// The ID of the message created by this run step. - public string MessageId { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMicrosoftFabricToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMicrosoftFabricToolCall.Serialization.cs deleted file mode 100644 index 987a9e708b62..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMicrosoftFabricToolCall.Serialization.cs +++ /dev/null @@ -1,151 +0,0 @@ -// 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 RunStepMicrosoftFabricToolCall : 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(RunStepMicrosoftFabricToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("fabric_dataagent"u8); - writer.WriteStartObject(); - foreach (var item in MicrosoftFabric) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - - RunStepMicrosoftFabricToolCall 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(RunStepMicrosoftFabricToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepMicrosoftFabricToolCall(document.RootElement, options); - } - - internal static RunStepMicrosoftFabricToolCall DeserializeRunStepMicrosoftFabricToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyDictionary fabricDataagent = default; - string type = default; - string id = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("fabric_dataagent"u8)) - { - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - fabricDataagent = 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 RunStepMicrosoftFabricToolCall(type, id, serializedAdditionalRawData, fabricDataagent); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepMicrosoftFabricToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepMicrosoftFabricToolCall 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 DeserializeRunStepMicrosoftFabricToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepMicrosoftFabricToolCall)} 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 RunStepMicrosoftFabricToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepMicrosoftFabricToolCall(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/RunStepMicrosoftFabricToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMicrosoftFabricToolCall.cs deleted file mode 100644 index 9cd55706d646..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepMicrosoftFabricToolCall.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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 Microsoft Fabric tool, issued by the model in evaluation of a defined tool, that represents - /// executed Microsoft Fabric operations. - /// - public partial class RunStepMicrosoftFabricToolCall : 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 RunStepMicrosoftFabricToolCall(string id, IReadOnlyDictionary microsoftFabric) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(microsoftFabric, nameof(microsoftFabric)); - - Type = "fabric_dataagent"; - MicrosoftFabric = microsoftFabric; - } - - /// 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 RunStepMicrosoftFabricToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary microsoftFabric) : base(type, id, serializedAdditionalRawData) - { - MicrosoftFabric = microsoftFabric; - } - - /// Initializes a new instance of for deserialization. - internal RunStepMicrosoftFabricToolCall() - { - } - - /// Reserved for future use. - public IReadOnlyDictionary MicrosoftFabric { 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 deleted file mode 100644 index d90fb7b78d29..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.Serialization.cs +++ /dev/null @@ -1,151 +0,0 @@ -// 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, AzureAIProjectsContext.Default); - 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 deleted file mode 100644 index 309a45d57ea0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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/RunStepSharepointToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepSharepointToolCall.cs deleted file mode 100644 index 3efabae62b69..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepSharepointToolCall.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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 SharePoint tool, issued by the model in evaluation of a defined tool, that represents - /// executed SharePoint actions. - /// - public partial class RunStepSharepointToolCall : 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 RunStepSharepointToolCall(string id, IReadOnlyDictionary sharePoint) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(sharePoint, nameof(sharePoint)); - - Type = "sharepoint_grounding"; - SharePoint = sharePoint; - } - - /// 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 RunStepSharepointToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary sharePoint) : base(type, id, serializedAdditionalRawData) - { - SharePoint = sharePoint; - } - - /// Initializes a new instance of for deserialization. - internal RunStepSharepointToolCall() - { - } - - /// Reserved for future use. - public IReadOnlyDictionary SharePoint { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepStatus.cs deleted file mode 100644 index f71c99e16db9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepStatus.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Possible values for the status of a run step. - public readonly partial struct RunStepStatus : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RunStepStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string CancelledValue = "cancelled"; - private const string FailedValue = "failed"; - private const string CompletedValue = "completed"; - private const string ExpiredValue = "expired"; - - /// Represents a run step still in progress. - public static RunStepStatus InProgress { get; } = new RunStepStatus(InProgressValue); - /// Represents a run step that was cancelled. - public static RunStepStatus Cancelled { get; } = new RunStepStatus(CancelledValue); - /// Represents a run step that failed. - public static RunStepStatus Failed { get; } = new RunStepStatus(FailedValue); - /// Represents a run step that successfully completed. - public static RunStepStatus Completed { get; } = new RunStepStatus(CompletedValue); - /// Represents a run step that expired before otherwise finishing. - public static RunStepStatus Expired { get; } = new RunStepStatus(ExpiredValue); - /// Determines if two values are the same. - public static bool operator ==(RunStepStatus left, RunStepStatus right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RunStepStatus left, RunStepStatus right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator RunStepStatus(string value) => new RunStepStatus(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepStatus other && Equals(other); - /// - public bool Equals(RunStepStatus 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/sdk/ai/Azure.AI.Projects/src/Generated/RunStepStreamEvent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepStreamEvent.cs deleted file mode 100644 index 423b575c14a9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepStreamEvent.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Run step operation related streaming events. - public readonly partial struct RunStepStreamEvent : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RunStepStreamEvent(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ThreadRunStepCreatedValue = "thread.run.step.created"; - private const string ThreadRunStepInProgressValue = "thread.run.step.in_progress"; - private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; - private const string ThreadRunStepCompletedValue = "thread.run.step.completed"; - private const string ThreadRunStepFailedValue = "thread.run.step.failed"; - private const string ThreadRunStepCancelledValue = "thread.run.step.cancelled"; - private const string ThreadRunStepExpiredValue = "thread.run.step.expired"; - - /// Event sent when a new thread run step is created. The data of this event is of type RunStep. - public static RunStepStreamEvent ThreadRunStepCreated { get; } = new RunStepStreamEvent(ThreadRunStepCreatedValue); - /// Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep. - public static RunStepStreamEvent ThreadRunStepInProgress { get; } = new RunStepStreamEvent(ThreadRunStepInProgressValue); - /// Event sent when a run step is being streamed. The data of this event is of type RunStepDeltaChunk. - public static RunStepStreamEvent ThreadRunStepDelta { get; } = new RunStepStreamEvent(ThreadRunStepDeltaValue); - /// Event sent when a run step is completed. The data of this event is of type RunStep. - public static RunStepStreamEvent ThreadRunStepCompleted { get; } = new RunStepStreamEvent(ThreadRunStepCompletedValue); - /// Event sent when a run step fails. The data of this event is of type RunStep. - public static RunStepStreamEvent ThreadRunStepFailed { get; } = new RunStepStreamEvent(ThreadRunStepFailedValue); - /// Event sent when a run step is cancelled. The data of this event is of type RunStep. - public static RunStepStreamEvent ThreadRunStepCancelled { get; } = new RunStepStreamEvent(ThreadRunStepCancelledValue); - /// Event sent when a run step is expired. The data of this event is of type RunStep. - public static RunStepStreamEvent ThreadRunStepExpired { get; } = new RunStepStreamEvent(ThreadRunStepExpiredValue); - /// Determines if two values are the same. - public static bool operator ==(RunStepStreamEvent left, RunStepStreamEvent right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RunStepStreamEvent left, RunStepStreamEvent right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator RunStepStreamEvent(string value) => new RunStepStreamEvent(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepStreamEvent other && Equals(other); - /// - public bool Equals(RunStepStreamEvent 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/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs deleted file mode 100644 index c427a0f4981d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownRunStepToolCall))] - public partial class RunStepToolCall : 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(RunStepToolCall)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - 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 - } - } - } - - RunStepToolCall 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(RunStepToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepToolCall(document.RootElement, options); - } - - internal static RunStepToolCall DeserializeRunStepToolCall(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_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); - } - } - return UnknownRunStepToolCall.DeserializeUnknownRunStepToolCall(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepToolCall 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 DeserializeRunStepToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepToolCall)} 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 RunStepToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepToolCall(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/RunStepToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.cs deleted file mode 100644 index a800f6a76157..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -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 . - /// - public abstract partial class RunStepToolCall - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// is null. - protected RunStepToolCall(string id) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - } - - /// 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. - internal RunStepToolCall(string type, string id, IDictionary serializedAdditionalRawData) - { - Type = type; - Id = id; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RunStepToolCall() - { - } - - /// The object type. - internal string Type { get; set; } - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - public string Id { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.Serialization.cs deleted file mode 100644 index a2b03512f3ca..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.Serialization.cs +++ /dev/null @@ -1,144 +0,0 @@ -// 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 RunStepToolCallDetails : 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(RunStepToolCallDetails)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("tool_calls"u8); - writer.WriteStartArray(); - foreach (var item in ToolCalls) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - - RunStepToolCallDetails 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(RunStepToolCallDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepToolCallDetails(document.RootElement, options); - } - - internal static RunStepToolCallDetails DeserializeRunStepToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList toolCalls = default; - RunStepType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("tool_calls"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepToolCall.DeserializeRunStepToolCall(item, options)); - } - toolCalls = array; - continue; - } - if (property.NameEquals("type"u8)) - { - type = new RunStepType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepToolCallDetails(type, serializedAdditionalRawData, toolCalls); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepToolCallDetails)} does not support writing '{options.Format}' format."); - } - } - - RunStepToolCallDetails 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 DeserializeRunStepToolCallDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepToolCallDetails)} 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 RunStepToolCallDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepToolCallDetails(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/RunStepToolCallDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.cs deleted file mode 100644 index 00e943d0854b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.cs +++ /dev/null @@ -1,57 +0,0 @@ -// 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 -{ - /// The detailed information associated with a run step calling tools. - public partial class RunStepToolCallDetails : RunStepDetails - { - /// Initializes a new instance of . - /// - /// 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 . - /// - /// is null. - internal RunStepToolCallDetails(IEnumerable toolCalls) - { - Argument.AssertNotNull(toolCalls, nameof(toolCalls)); - - Type = RunStepType.ToolCalls; - ToolCalls = toolCalls.ToList(); - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// - /// 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 . - /// - internal RunStepToolCallDetails(RunStepType type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) - { - ToolCalls = toolCalls; - } - - /// Initializes a new instance of for deserialization. - 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 . - /// - public IReadOnlyList ToolCalls { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepType.cs deleted file mode 100644 index b3e4153be1e9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepType.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The possible types of run steps. - public readonly partial struct RunStepType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RunStepType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string MessageCreationValue = "message_creation"; - private const string ToolCallsValue = "tool_calls"; - - /// Represents a run step to create a message. - public static RunStepType MessageCreation { get; } = new RunStepType(MessageCreationValue); - /// Represents a run step that calls tools. - public static RunStepType ToolCalls { get; } = new RunStepType(ToolCallsValue); - /// Determines if two values are the same. - public static bool operator ==(RunStepType left, RunStepType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RunStepType left, RunStepType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator RunStepType(string value) => new RunStepType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepType other && Equals(other); - /// - public bool Equals(RunStepType 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/sdk/ai/Azure.AI.Projects/src/Generated/RunStreamEvent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStreamEvent.cs deleted file mode 100644 index b3fd0dcab2ef..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStreamEvent.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Run operation related streaming events. - public readonly partial struct RunStreamEvent : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RunStreamEvent(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ThreadRunCreatedValue = "thread.run.created"; - private const string ThreadRunQueuedValue = "thread.run.queued"; - private const string ThreadRunInProgressValue = "thread.run.in_progress"; - private const string ThreadRunRequiresActionValue = "thread.run.requires_action"; - private const string ThreadRunCompletedValue = "thread.run.completed"; - private const string ThreadRunIncompleteValue = "thread.run.incomplete"; - private const string ThreadRunFailedValue = "thread.run.failed"; - private const string ThreadRunCancellingValue = "thread.run.cancelling"; - private const string ThreadRunCancelledValue = "thread.run.cancelled"; - private const string ThreadRunExpiredValue = "thread.run.expired"; - - /// Event sent when a new run is created. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunCreated { get; } = new RunStreamEvent(ThreadRunCreatedValue); - /// Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunQueued { get; } = new RunStreamEvent(ThreadRunQueuedValue); - /// Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunInProgress { get; } = new RunStreamEvent(ThreadRunInProgressValue); - /// Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunRequiresAction { get; } = new RunStreamEvent(ThreadRunRequiresActionValue); - /// Event sent when a run is completed. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunCompleted { get; } = new RunStreamEvent(ThreadRunCompletedValue); - /// Event sent when a run ends incomplete. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunIncomplete { get; } = new RunStreamEvent(ThreadRunIncompleteValue); - /// Event sent when a run fails. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunFailed { get; } = new RunStreamEvent(ThreadRunFailedValue); - /// Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunCancelling { get; } = new RunStreamEvent(ThreadRunCancellingValue); - /// Event sent when a run is cancelled. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunCancelled { get; } = new RunStreamEvent(ThreadRunCancelledValue); - /// Event sent when a run is expired. The data of this event is of type ThreadRun. - public static RunStreamEvent ThreadRunExpired { get; } = new RunStreamEvent(ThreadRunExpiredValue); - /// Determines if two values are the same. - public static bool operator ==(RunStreamEvent left, RunStreamEvent right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RunStreamEvent left, RunStreamEvent right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator RunStreamEvent(string value) => new RunStreamEvent(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStreamEvent other && Equals(other); - /// - public bool Equals(RunStreamEvent 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/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SASCredentials.Serialization.cs similarity index 62% rename from sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageContent.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/SASCredentials.Serialization.cs index fac62a0cb7ab..879d94645b85 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageContent.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SASCredentials.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class UnknownMessageContent : IUtf8JsonSerializable, IJsonModel + public partial class SASCredentials : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,28 +28,33 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(SASCredentials)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); + if (options.Format != "W" && Optional.IsDefined(SasToken)) + { + writer.WritePropertyName("SAS"u8); + writer.WriteStringValue(SasToken); + } } - MessageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + SASCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(SASCredentials)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageContent(document.RootElement, options); + return DeserializeSASCredentials(document.RootElement, options); } - internal static UnknownMessageContent DeserializeUnknownMessageContent(JsonElement element, ModelReaderWriterOptions options = null) + internal static SASCredentials DeserializeSASCredentials(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -57,14 +62,20 @@ internal static UnknownMessageContent DeserializeUnknownMessageContent(JsonEleme { return null; } - string type = "Unknown"; + string sas = default; + CredentialType type = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("SAS"u8)) + { + sas = property.Value.GetString(); + continue; + } if (property.NameEquals("type"u8)) { - type = property.Value.GetString(); + type = new CredentialType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -73,53 +84,53 @@ internal static UnknownMessageContent DeserializeUnknownMessageContent(JsonEleme } } serializedAdditionalRawData = rawDataDictionary; - return new UnknownMessageContent(type, serializedAdditionalRawData); + return new SASCredentials(type, serializedAdditionalRawData, sas); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(SASCredentials)} does not support writing '{options.Format}' format."); } } - MessageContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + SASCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeMessageContent(document.RootElement, options); + return DeserializeSASCredentials(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(SASCredentials)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new UnknownMessageContent FromResponse(Response response) + internal static new SASCredentials FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownMessageContent(document.RootElement); + return DeserializeSASCredentials(document.RootElement); } /// Convert into a . internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SASCredentials.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SASCredentials.cs new file mode 100644 index 000000000000..0ecd9e30ef63 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SASCredentials.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Shared Access Signature (SAS) credential definition. + public partial class SASCredentials : BaseCredentials + { + /// Initializes a new instance of . + internal SASCredentials() + { + Type = CredentialType.SAS; + } + + /// Initializes a new instance of . + /// The type of credential used by the connection. + /// Keeps track of any properties unknown to the library. + /// SAS token. + internal SASCredentials(CredentialType type, IDictionary serializedAdditionalRawData, string sasToken) : base(type, serializedAdditionalRawData) + { + SasToken = sasToken; + } + + /// SAS token. + public string SasToken { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SasCredential.Serialization.cs similarity index 62% rename from sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContent.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/SasCredential.Serialization.cs index ef5f0fc4ea59..3a15498df124 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileSearchToolCallContent.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SasCredential.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class FileSearchToolCallContent : IUtf8JsonSerializable, IJsonModel + public partial class SasCredential : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,16 +28,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(FileSearchToolCallContent)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(SasCredential)} does not support writing '{format}' format."); } + if (options.Format != "W") + { + writer.WritePropertyName("sasUri"u8); + writer.WriteStringValue(SasUri); + } writer.WritePropertyName("type"u8); writer.WriteStringValue(Type.ToString()); - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -55,19 +58,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - FileSearchToolCallContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + SasCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(FileSearchToolCallContent)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(SasCredential)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileSearchToolCallContent(document.RootElement, options); + return DeserializeSasCredential(document.RootElement, options); } - internal static FileSearchToolCallContent DeserializeFileSearchToolCallContent(JsonElement element, ModelReaderWriterOptions options = null) + internal static SasCredential DeserializeSasCredential(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -75,20 +78,20 @@ internal static FileSearchToolCallContent DeserializeFileSearchToolCallContent(J { return null; } - FileSearchToolCallContentType type = default; - string text = default; + string sasUri = default; + SasCredentialType type = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("type"u8)) + if (property.NameEquals("sasUri"u8)) { - type = new FileSearchToolCallContentType(property.Value.GetString()); + sasUri = property.Value.GetString(); continue; } - if (property.NameEquals("text"u8)) + if (property.NameEquals("type"u8)) { - text = property.Value.GetString(); + type = new SasCredentialType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -97,46 +100,46 @@ internal static FileSearchToolCallContent DeserializeFileSearchToolCallContent(J } } serializedAdditionalRawData = rawDataDictionary; - return new FileSearchToolCallContent(type, text, serializedAdditionalRawData); + return new SasCredential(sasUri, type, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(FileSearchToolCallContent)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(SasCredential)} does not support writing '{options.Format}' format."); } } - FileSearchToolCallContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + SasCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFileSearchToolCallContent(document.RootElement, options); + return DeserializeSasCredential(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(FileSearchToolCallContent)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(SasCredential)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static FileSearchToolCallContent FromResponse(Response response) + internal static SasCredential FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFileSearchToolCallContent(document.RootElement); + return DeserializeSasCredential(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreationObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SasCredential.cs similarity index 69% rename from sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreationObject.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/SasCredential.cs index 076a5a1114fc..d0fa68cb5724 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaMessageCreationObject.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SasCredential.cs @@ -10,8 +10,8 @@ namespace Azure.AI.Projects { - /// Represents the data within a streaming run step message creation response object. - public partial class RunStepDeltaMessageCreationObject + /// SAS Credential definition. + public partial class SasCredential { /// /// Keeps track of any properties unknown to the library. @@ -45,21 +45,25 @@ public partial class RunStepDeltaMessageCreationObject /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - internal RunStepDeltaMessageCreationObject() + /// Initializes a new instance of . + internal SasCredential() { } - /// Initializes a new instance of . - /// The ID of the newly-created message. + /// Initializes a new instance of . + /// SAS uri. + /// Type of credential. /// Keeps track of any properties unknown to the library. - internal RunStepDeltaMessageCreationObject(string messageId, IDictionary serializedAdditionalRawData) + internal SasCredential(string sasUri, SasCredentialType type, IDictionary serializedAdditionalRawData) { - MessageId = messageId; + SasUri = sasUri; + Type = type; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// The ID of the newly-created message. - public string MessageId { get; } + /// SAS uri. + public string SasUri { get; } + /// Type of credential. + public SasCredentialType Type { get; } = SasCredentialType.SAS; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SasCredentialType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SasCredentialType.cs new file mode 100644 index 000000000000..3fc9ddca9a2c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SasCredentialType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The SasCredential_type. + public readonly partial struct SasCredentialType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SasCredentialType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SASValue = "SAS"; + + /// SAS. + public static SasCredentialType SAS { get; } = new SasCredentialType(SASValue); + /// Determines if two values are the same. + public static bool operator ==(SasCredentialType left, SasCredentialType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SasCredentialType left, SasCredentialType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SasCredentialType(string value) => new SasCredentialType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SasCredentialType other && Equals(other); + /// + public bool Equals(SasCredentialType 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/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.Serialization.cs deleted file mode 100644 index c52a53d1e4ed..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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, AzureAIProjectsContext.Default); - 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 deleted file mode 100644 index 8885b81cd971..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.cs +++ /dev/null @@ -1,82 +0,0 @@ -// 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 deleted file mode 100644 index 94dc90fc64a4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.Serialization.cs +++ /dev/null @@ -1,152 +0,0 @@ -// 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, AzureAIProjectsContext.Default); - 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/ServicePatterns.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ServicePatterns.cs new file mode 100644 index 000000000000..3299ecf99b1f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ServicePatterns.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects +{ + // Data plane generated sub-client. + /// The ServicePatterns sub-client. + public partial class ServicePatterns + { + private static readonly string[] AuthorizationScopes = new string[] { "https://ai.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of ServicePatterns for mocking. + protected ServicePatterns() + { + } + + /// Initializes a new instance of ServicePatterns. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// + /// Project endpoint. In the form "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" + /// if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + /// "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" if you want to explicitly + /// specify the Foundry Project name. + /// + internal ServicePatterns(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SharepointToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointToolDefinition.Serialization.cs deleted file mode 100644 index 19a15f202f5a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SharepointToolDefinition.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 SharepointToolDefinition : 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(SharepointToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("sharepoint_grounding"u8); - writer.WriteObjectValue(SharepointGrounding, options); - } - - SharepointToolDefinition 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(SharepointToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSharepointToolDefinition(document.RootElement, options); - } - - internal static SharepointToolDefinition DeserializeSharepointToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ToolConnectionList sharepointGrounding = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("sharepoint_grounding"u8)) - { - sharepointGrounding = ToolConnectionList.DeserializeToolConnectionList(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 SharepointToolDefinition(type, serializedAdditionalRawData, sharepointGrounding); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(SharepointToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - SharepointToolDefinition 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 DeserializeSharepointToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SharepointToolDefinition)} 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 SharepointToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeSharepointToolDefinition(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/SharepointToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointToolDefinition.cs deleted file mode 100644 index 45c89ce5271f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SharepointToolDefinition.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 sharepoint tool as used to configure an agent. - public partial class SharepointToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - /// The list of connections used by the SharePoint tool. - /// is null. - public SharepointToolDefinition(ToolConnectionList sharepointGrounding) - { - Argument.AssertNotNull(sharepointGrounding, nameof(sharepointGrounding)); - - Type = "sharepoint_grounding"; - SharepointGrounding = sharepointGrounding; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The list of connections used by the SharePoint tool. - internal SharepointToolDefinition(string type, IDictionary serializedAdditionalRawData, ToolConnectionList sharepointGrounding) : base(type, serializedAdditionalRawData) - { - SharepointGrounding = sharepointGrounding; - } - - /// Initializes a new instance of for deserialization. - internal SharepointToolDefinition() - { - } - - /// The list of connections used by the SharePoint tool. - public ToolConnectionList SharepointGrounding { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Sku.Serialization.cs similarity index 60% rename from sdk/ai/Azure.AI.Projects/src/Generated/ConnectionResponse.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/Sku.Serialization.cs index a928ddd24acc..bfd0756053ec 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionResponse.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Sku.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class ConnectionResponse : IUtf8JsonSerializable, IJsonModel + public partial class Sku : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,18 +28,22 @@ 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ConnectionResponse)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(Sku)} does not support writing '{format}' format."); } - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WritePropertyName("capacity"u8); + writer.WriteNumberValue(Capacity); + writer.WritePropertyName("family"u8); + writer.WriteStringValue(Family); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - writer.WritePropertyName("properties"u8); - writer.WriteObjectValue(Properties, options); + writer.WritePropertyName("size"u8); + writer.WriteStringValue(Size); + writer.WritePropertyName("tier"u8); + writer.WriteStringValue(Tier); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -57,19 +61,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ConnectionResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + Sku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ConnectionResponse)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(Sku)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeConnectionResponse(document.RootElement, options); + return DeserializeSku(document.RootElement, options); } - internal static ConnectionResponse DeserializeConnectionResponse(JsonElement element, ModelReaderWriterOptions options = null) + internal static Sku DeserializeSku(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,16 +81,23 @@ internal static ConnectionResponse DeserializeConnectionResponse(JsonElement ele { return null; } - string id = default; + long capacity = default; + string family = default; string name = default; - ConnectionProperties properties = default; + string size = default; + string tier = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (property.NameEquals("capacity"u8)) { - id = property.Value.GetString(); + capacity = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("family"u8)) + { + family = property.Value.GetString(); continue; } if (property.NameEquals("name"u8)) @@ -94,9 +105,14 @@ internal static ConnectionResponse DeserializeConnectionResponse(JsonElement ele name = property.Value.GetString(); continue; } - if (property.NameEquals("properties"u8)) + if (property.NameEquals("size"u8)) + { + size = property.Value.GetString(); + continue; + } + if (property.NameEquals("tier"u8)) { - properties = ConnectionProperties.DeserializeConnectionProperties(property.Value, options); + tier = property.Value.GetString(); continue; } if (options.Format != "W") @@ -105,46 +121,52 @@ internal static ConnectionResponse DeserializeConnectionResponse(JsonElement ele } } serializedAdditionalRawData = rawDataDictionary; - return new ConnectionResponse(id, name, properties, serializedAdditionalRawData); + return new Sku( + capacity, + family, + name, + size, + tier, + serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(ConnectionResponse)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(Sku)} does not support writing '{options.Format}' format."); } } - ConnectionResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + Sku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeConnectionResponse(document.RootElement, options); + return DeserializeSku(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(ConnectionResponse)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(Sku)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static ConnectionResponse FromResponse(Response response) + internal static Sku FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeConnectionResponse(document.RootElement); + return DeserializeSku(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Sku.cs similarity index 52% rename from sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/Sku.cs index 8847f00e6f20..f89d0c5ea9ff 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Sku.cs @@ -7,12 +7,11 @@ 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 + /// Sku information. + public partial class Sku { /// /// Keeps track of any properties unknown to the library. @@ -46,40 +45,58 @@ public partial class SearchConfigurationList /// 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) + /// Initializes a new instance of . + /// Sku capacity. + /// Sku family. + /// Sku name. + /// Sku size. + /// Sku tier. + /// , , or is null. + internal Sku(long capacity, string family, string name, string size, string tier) { - Argument.AssertNotNull(searchConfigurations, nameof(searchConfigurations)); + Argument.AssertNotNull(family, nameof(family)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(size, nameof(size)); + Argument.AssertNotNull(tier, nameof(tier)); - SearchConfigurations = searchConfigurations.ToList(); + Capacity = capacity; + Family = family; + Name = name; + Size = size; + Tier = tier; } - /// Initializes a new instance of . - /// - /// The connections attached to this tool. There can be a maximum of 1 connection - /// resource attached to the tool. - /// + /// Initializes a new instance of . + /// Sku capacity. + /// Sku family. + /// Sku name. + /// Sku size. + /// Sku tier. /// Keeps track of any properties unknown to the library. - internal SearchConfigurationList(IList searchConfigurations, IDictionary serializedAdditionalRawData) + internal Sku(long capacity, string family, string name, string size, string tier, IDictionary serializedAdditionalRawData) { - SearchConfigurations = searchConfigurations; + Capacity = capacity; + Family = family; + Name = name; + Size = size; + Tier = tier; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal SearchConfigurationList() + /// Initializes a new instance of for deserialization. + internal Sku() { } - /// - /// The connections attached to this tool. There can be a maximum of 1 connection - /// resource attached to the tool. - /// - public IList SearchConfigurations { get; } + /// Sku capacity. + public long Capacity { get; } + /// Sku family. + public string Family { get; } + /// Sku name. + public string Name { get; } + /// Sku size. + public string Size { get; } + /// Sku tier. + public string Tier { get; } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsAction.Serialization.cs deleted file mode 100644 index 4cdb779f1bae..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsAction.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 SubmitToolOutputsAction : 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(SubmitToolOutputsAction)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("submit_tool_outputs"u8); - writer.WriteObjectValue(InternalDetails, options); - } - - SubmitToolOutputsAction 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(SubmitToolOutputsAction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSubmitToolOutputsAction(document.RootElement, options); - } - - internal static SubmitToolOutputsAction DeserializeSubmitToolOutputsAction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalSubmitToolOutputsDetails submitToolOutputs = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("submit_tool_outputs"u8)) - { - submitToolOutputs = InternalSubmitToolOutputsDetails.DeserializeInternalSubmitToolOutputsDetails(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 SubmitToolOutputsAction(type, serializedAdditionalRawData, submitToolOutputs); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(SubmitToolOutputsAction)} does not support writing '{options.Format}' format."); - } - } - - SubmitToolOutputsAction 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 DeserializeSubmitToolOutputsAction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SubmitToolOutputsAction)} 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 SubmitToolOutputsAction FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeSubmitToolOutputsAction(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/SubmitToolOutputsAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsAction.cs deleted file mode 100644 index 55b71a82960e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsAction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// 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 details for required tool calls that must be submitted for an agent thread run to continue. - public partial class SubmitToolOutputsAction : RequiredAction - { - /// Initializes a new instance of . - /// The details describing tools that should be called to submit tool outputs. - /// is null. - internal SubmitToolOutputsAction(InternalSubmitToolOutputsDetails internalDetails) - { - Argument.AssertNotNull(internalDetails, nameof(internalDetails)); - - Type = "submit_tool_outputs"; - InternalDetails = internalDetails; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The details describing tools that should be called to submit tool outputs. - internal SubmitToolOutputsAction(string type, IDictionary serializedAdditionalRawData, InternalSubmitToolOutputsDetails internalDetails) : base(type, serializedAdditionalRawData) - { - InternalDetails = internalDetails; - } - - /// Initializes a new instance of for deserialization. - internal SubmitToolOutputsAction() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs deleted file mode 100644 index 659c5ddb6333..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs +++ /dev/null @@ -1,175 +0,0 @@ -// 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 -{ - internal partial class SubmitToolOutputsToRunRequest : 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(SubmitToolOutputsToRunRequest)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("tool_outputs"u8); - writer.WriteStartArray(); - foreach (var item in ToolOutputs) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - if (Optional.IsDefined(Stream)) - { - if (Stream != null) - { - writer.WritePropertyName("stream"u8); - writer.WriteBooleanValue(Stream.Value); - } - else - { - writer.WriteNull("stream"); - } - } - 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 - } - } - } - - SubmitToolOutputsToRunRequest 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(SubmitToolOutputsToRunRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSubmitToolOutputsToRunRequest(document.RootElement, options); - } - - internal static SubmitToolOutputsToRunRequest DeserializeSubmitToolOutputsToRunRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList toolOutputs = default; - bool? stream = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("tool_outputs"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolOutput.DeserializeToolOutput(item, options)); - } - toolOutputs = array; - continue; - } - if (property.NameEquals("stream"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - stream = null; - continue; - } - stream = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new SubmitToolOutputsToRunRequest(toolOutputs, stream, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(SubmitToolOutputsToRunRequest)} does not support writing '{options.Format}' format."); - } - } - - SubmitToolOutputsToRunRequest 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 DeserializeSubmitToolOutputsToRunRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SubmitToolOutputsToRunRequest)} 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 SubmitToolOutputsToRunRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeSubmitToolOutputsToRunRequest(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/SubmitToolOutputsToRunRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsToRunRequest.cs deleted file mode 100644 index ce70a43ea179..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SubmitToolOutputsToRunRequest.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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 -{ - /// The SubmitToolOutputsToRunRequest. - internal partial class SubmitToolOutputsToRunRequest - { - /// - /// 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 list of tools for which the outputs are being submitted. - /// is null. - internal SubmitToolOutputsToRunRequest(IEnumerable toolOutputs) - { - Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); - - ToolOutputs = toolOutputs.ToList(); - } - - /// Initializes a new instance of . - /// A list of tools for which the outputs are being submitted. - /// If true, returns a stream of events that happen during the Run as server-sent events, terminating when the run enters a terminal state. - /// Keeps track of any properties unknown to the library. - internal SubmitToolOutputsToRunRequest(IReadOnlyList toolOutputs, bool? stream, IDictionary serializedAdditionalRawData) - { - ToolOutputs = toolOutputs; - Stream = stream; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal SubmitToolOutputsToRunRequest() - { - } - - /// A list of tools for which the outputs are being submitted. - public IReadOnlyList ToolOutputs { get; } - /// If true, returns a stream of events that happen during the Run as server-sent events, terminating when the run enters a terminal state. - public bool? Stream { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SystemData.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SystemData.Serialization.cs deleted file mode 100644 index 41118c3cb353..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SystemData.Serialization.cs +++ /dev/null @@ -1,186 +0,0 @@ -// 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 SystemData : 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(SystemData)} does not support writing '{format}' format."); - } - - if (options.Format != "W" && Optional.IsDefined(CreatedAt)) - { - writer.WritePropertyName("createdAt"u8); - writer.WriteStringValue(CreatedAt.Value, "O"); - } - if (options.Format != "W" && Optional.IsDefined(CreatedBy)) - { - writer.WritePropertyName("createdBy"u8); - writer.WriteStringValue(CreatedBy); - } - if (options.Format != "W" && Optional.IsDefined(CreatedByType)) - { - writer.WritePropertyName("createdByType"u8); - writer.WriteStringValue(CreatedByType); - } - if (options.Format != "W" && Optional.IsDefined(LastModifiedAt)) - { - writer.WritePropertyName("lastModifiedAt"u8); - writer.WriteStringValue(LastModifiedAt.Value, "O"); - } - 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 - } - } - } - - SystemData 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(SystemData)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSystemData(document.RootElement, options); - } - - internal static SystemData DeserializeSystemData(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - DateTimeOffset? createdAt = default; - string createdBy = default; - string createdByType = default; - DateTimeOffset? lastModifiedAt = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("createdAt"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - createdAt = property.Value.GetDateTimeOffset("O"); - continue; - } - if (property.NameEquals("createdBy"u8)) - { - createdBy = property.Value.GetString(); - continue; - } - if (property.NameEquals("createdByType"u8)) - { - createdByType = property.Value.GetString(); - continue; - } - if (property.NameEquals("lastModifiedAt"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - lastModifiedAt = property.Value.GetDateTimeOffset("O"); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new SystemData(createdAt, createdBy, createdByType, lastModifiedAt, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(SystemData)} does not support writing '{options.Format}' format."); - } - } - - SystemData 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 DeserializeSystemData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SystemData)} 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 SystemData FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeSystemData(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/SystemData.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SystemData.cs deleted file mode 100644 index b7ffe4c91fe8..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/SystemData.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Metadata pertaining to creation and last modification of the resource. - public partial class SystemData - { - /// - /// 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 . - internal SystemData() - { - } - - /// Initializes a new instance of . - /// The timestamp the resource was created at. - /// The identity that created the resource. - /// The identity type that created the resource. - /// The timestamp of resource last modification (UTC). - /// Keeps track of any properties unknown to the library. - internal SystemData(DateTimeOffset? createdAt, string createdBy, string createdByType, DateTimeOffset? lastModifiedAt, IDictionary serializedAdditionalRawData) - { - CreatedAt = createdAt; - CreatedBy = createdBy; - CreatedByType = createdByType; - LastModifiedAt = lastModifiedAt; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The timestamp the resource was created at. - public DateTimeOffset? CreatedAt { get; } - /// The identity that created the resource. - public string CreatedBy { get; } - /// The identity type that created the resource. - public string CreatedByType { get; } - /// The timestamp of resource last modification (UTC). - public DateTimeOffset? LastModifiedAt { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TargetModelConfig.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.Serialization.cs similarity index 63% rename from sdk/ai/Azure.AI.Projects/src/Generated/TargetModelConfig.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.Serialization.cs index 7f0e77a8f0bc..6c4eec42dbc3 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/TargetModelConfig.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.Serialization.cs @@ -12,12 +12,12 @@ namespace Azure.AI.Projects { - [PersistableModelProxy(typeof(UnknownTargetModelConfig))] - public partial class TargetModelConfig : IUtf8JsonSerializable, IJsonModel + [PersistableModelProxy(typeof(UnknownTargetConfig))] + public partial class TargetConfig : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,10 +28,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(TargetModelConfig)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(TargetConfig)} does not support writing '{format}' format."); } writer.WritePropertyName("type"u8); @@ -53,19 +53,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TargetModelConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + TargetConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(TargetModelConfig)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(TargetConfig)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTargetModelConfig(document.RootElement, options); + return DeserializeTargetConfig(document.RootElement, options); } - internal static TargetModelConfig DeserializeTargetModelConfig(JsonElement element, ModelReaderWriterOptions options = null) + internal static TargetConfig DeserializeTargetConfig(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -77,50 +77,49 @@ internal static TargetModelConfig DeserializeTargetModelConfig(JsonElement eleme { switch (discriminator.GetString()) { - case "AOAI": return AOAIModelConfig.DeserializeAOAIModelConfig(element, options); - case "MAAS": return MAASModelConfig.DeserializeMAASModelConfig(element, options); + case "AzureOpenAIModel": return AzureOpenAIModelConfiguration.DeserializeAzureOpenAIModelConfiguration(element, options); } } - return UnknownTargetModelConfig.DeserializeUnknownTargetModelConfig(element, options); + return UnknownTargetConfig.DeserializeUnknownTargetConfig(element, options); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(TargetModelConfig)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(TargetConfig)} does not support writing '{options.Format}' format."); } } - TargetModelConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + TargetConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTargetModelConfig(document.RootElement, options); + return DeserializeTargetConfig(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(TargetModelConfig)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(TargetConfig)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static TargetModelConfig FromResponse(Response response) + internal static TargetConfig FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTargetModelConfig(document.RootElement); + return DeserializeTargetConfig(document.RootElement); } /// Convert into a . diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TargetModelConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.cs similarity index 77% rename from sdk/ai/Azure.AI.Projects/src/Generated/TargetModelConfig.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.cs index a8f5c27ef5ea..cd3d02638de7 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/TargetModelConfig.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.cs @@ -11,11 +11,11 @@ namespace Azure.AI.Projects { /// - /// Abstract class for model configuration. - /// 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 . + /// Abstract class for target configuration. + /// 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 . /// - public abstract partial class TargetModelConfig + public abstract partial class TargetConfig { /// /// Keeps track of any properties unknown to the library. @@ -49,15 +49,15 @@ public abstract partial class TargetModelConfig /// private protected IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - protected TargetModelConfig() + /// Initializes a new instance of . + protected TargetConfig() { } - /// Initializes a new instance of . + /// Initializes a new instance of . /// Type of the model configuration. /// Keeps track of any properties unknown to the library. - internal TargetModelConfig(string type, IDictionary serializedAdditionalRawData) + internal TargetConfig(string type, IDictionary serializedAdditionalRawData) { Type = type; _serializedAdditionalRawData = serializedAdditionalRawData; diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TelemetryClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TelemetryClient.cs deleted file mode 100644 index 2732da6a60da..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/TelemetryClient.cs +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.AI.Projects -{ - // Data plane generated sub-client. - /// The Telemetry sub-client. - public partial class TelemetryClient - { - private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com/.default" }; - private readonly TokenCredential _tokenCredential; - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _subscriptionId; - private readonly string _resourceGroupName; - private readonly string _projectName; - private readonly string _apiVersion; - - /// The ClientDiagnostics is used to provide tracing support for the client library. - internal ClientDiagnostics ClientDiagnostics { get; } - - /// The HTTP pipeline for sending and receiving REST requests and responses. - public virtual HttpPipeline Pipeline => _pipeline; - - /// Initializes a new instance of TelemetryClient for mocking. - protected TelemetryClient() - { - } - - /// Initializes a new instance of TelemetryClient. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The token credential to copy. - /// The Azure AI Foundry project endpoint, in the form `https://<azure-region>.api.azureml.ms` or `https://<private-link-guid>.<azure-region>.api.azureml.ms`, where <azure-region> is the Azure region where the project is deployed (e.g. westus) and <private-link-guid> is the GUID of the Enterprise private link. - /// The Azure subscription ID. - /// The name of the Azure Resource Group. - /// The Azure AI Foundry project name. - /// The API version to use for this operation. - internal TelemetryClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string subscriptionId, string resourceGroupName, string projectName, string apiVersion) - { - ClientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - _tokenCredential = tokenCredential; - _endpoint = endpoint; - _subscriptionId = subscriptionId; - _resourceGroupName = resourceGroupName; - _projectName = projectName; - _apiVersion = apiVersion; - } - - /// Gets the properties of the specified Application Insights resource. - /// The AppInsights Azure resource Url. It should have the format: '/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/microsoft.insights/components/{resourcename}'. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> GetAppInsightsAsync(string appInsightsResourceUrl, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(appInsightsResourceUrl, nameof(appInsightsResourceUrl)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetAppInsightsAsync(appInsightsResourceUrl, context).ConfigureAwait(false); - return Response.FromValue(GetAppInsightsResponse.FromResponse(response), response); - } - - /// Gets the properties of the specified Application Insights resource. - /// The AppInsights Azure resource Url. It should have the format: '/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/microsoft.insights/components/{resourcename}'. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response GetAppInsights(string appInsightsResourceUrl, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(appInsightsResourceUrl, nameof(appInsightsResourceUrl)); - - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetAppInsights(appInsightsResourceUrl, context); - return Response.FromValue(GetAppInsightsResponse.FromResponse(response), response); - } - - /// - /// [Protocol Method] Gets the properties of the specified Application Insights resource - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The AppInsights Azure resource Url. It should have the format: '/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/microsoft.insights/components/{resourcename}'. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual async Task GetAppInsightsAsync(string appInsightsResourceUrl, RequestContext context) - { - Argument.AssertNotNullOrEmpty(appInsightsResourceUrl, nameof(appInsightsResourceUrl)); - - using var scope = ClientDiagnostics.CreateScope("TelemetryClient.GetAppInsights"); - scope.Start(); - try - { - using HttpMessage message = CreateGetAppInsightsRequest(appInsightsResourceUrl, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Gets the properties of the specified Application Insights resource - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The AppInsights Azure resource Url. It should have the format: '/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/microsoft.insights/components/{resourcename}'. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. - /// Service returned a non-success status code. - /// The response returned from the service. - internal virtual Response GetAppInsights(string appInsightsResourceUrl, RequestContext context) - { - Argument.AssertNotNullOrEmpty(appInsightsResourceUrl, nameof(appInsightsResourceUrl)); - - using var scope = ClientDiagnostics.CreateScope("TelemetryClient.GetAppInsights"); - scope.Start(); - try - { - using HttpMessage message = CreateGetAppInsightsRequest(appInsightsResourceUrl, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - internal HttpMessage CreateGetAppInsightsRequest(string appInsightsResourceUrl, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/agents/v1.0/subscriptions/", false); - uri.AppendRaw(_subscriptionId, true); - uri.AppendRaw("/resourceGroups/", false); - uri.AppendRaw(_resourceGroupName, true); - uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); - uri.AppendRaw(_projectName, true); - uri.AppendPath("/", false); - uri.AppendPath(appInsightsResourceUrl, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - private static RequestContext DefaultRequestContext = new RequestContext(); - internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) - { - if (!cancellationToken.CanBeCanceled) - { - return DefaultRequestContext; - } - - return new RequestContext() { CancellationToken = cancellationToken }; - } - - private static ResponseClassifier _responseClassifier200; - private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatus.cs deleted file mode 100644 index 5b2792458b1c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatus.cs +++ /dev/null @@ -1,85 +0,0 @@ -// 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 status of a thread deletion operation. - internal partial class ThreadDeletionStatus - { - /// - /// 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 ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// is null. - internal ThreadDeletionStatus(string id, bool deleted) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - Deleted = deleted; - } - - /// Initializes a new instance of . - /// The ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// The object type, which is always 'thread.deleted'. - /// Keeps track of any properties unknown to the library. - internal ThreadDeletionStatus(string id, bool deleted, ThreadDeletionStatusObject @object, IDictionary serializedAdditionalRawData) - { - Id = id; - Deleted = deleted; - Object = @object; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ThreadDeletionStatus() - { - } - - /// The ID of the resource specified for deletion. - public string Id { get; } - /// A value indicating whether deletion was successful. - public bool Deleted { get; } - /// The object type, which is always 'thread.deleted'. - public ThreadDeletionStatusObject Object { get; } = ThreadDeletionStatusObject.ThreadDeleted; - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatusObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatusObject.cs deleted file mode 100644 index 451e04bbddd6..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadDeletionStatusObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The ThreadDeletionStatus_object. - internal readonly partial struct ThreadDeletionStatusObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public ThreadDeletionStatusObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ThreadDeletedValue = "thread.deleted"; - - /// thread.deleted. - public static ThreadDeletionStatusObject ThreadDeleted { get; } = new ThreadDeletionStatusObject(ThreadDeletedValue); - /// Determines if two values are the same. - public static bool operator ==(ThreadDeletionStatusObject left, ThreadDeletionStatusObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(ThreadDeletionStatusObject left, ThreadDeletionStatusObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator ThreadDeletionStatusObject(string value) => new ThreadDeletionStatusObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ThreadDeletionStatusObject other && Equals(other); - /// - public bool Equals(ThreadDeletionStatusObject 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/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessage.Serialization.cs deleted file mode 100644 index df2eb6f07da3..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessage.Serialization.cs +++ /dev/null @@ -1,376 +0,0 @@ -// 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 ThreadMessage : 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(ThreadMessage)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - writer.WritePropertyName("thread_id"u8); - writer.WriteStringValue(ThreadId); - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); - if (IncompleteDetails != null) - { - writer.WritePropertyName("incomplete_details"u8); - writer.WriteObjectValue(IncompleteDetails, options); - } - else - { - writer.WriteNull("incomplete_details"); - } - if (CompletedAt != null) - { - writer.WritePropertyName("completed_at"u8); - writer.WriteNumberValue(CompletedAt.Value, "U"); - } - else - { - writer.WriteNull("completed_at"); - } - if (IncompleteAt != null) - { - writer.WritePropertyName("incomplete_at"u8); - writer.WriteNumberValue(IncompleteAt.Value, "U"); - } - else - { - writer.WriteNull("incomplete_at"); - } - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToString()); - writer.WritePropertyName("content"u8); - writer.WriteStartArray(); - foreach (var item in ContentItems) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - if (AssistantId != null) - { - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); - } - else - { - writer.WriteNull("assistant_id"); - } - if (RunId != null) - { - writer.WritePropertyName("run_id"u8); - writer.WriteStringValue(RunId); - } - else - { - writer.WriteNull("run_id"); - } - if (Attachments != null && Optional.IsCollectionDefined(Attachments)) - { - writer.WritePropertyName("attachments"u8); - writer.WriteStartArray(); - foreach (var item in Attachments) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("attachments"); - } - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - 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 - } - } - } - - ThreadMessage 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(ThreadMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadMessage(document.RootElement, options); - } - - internal static ThreadMessage DeserializeThreadMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - string @object = default; - DateTimeOffset createdAt = default; - string threadId = default; - MessageStatus status = default; - MessageIncompleteDetails incompleteDetails = default; - DateTimeOffset? completedAt = default; - DateTimeOffset? incompleteAt = default; - MessageRole role = default; - IReadOnlyList content = default; - string assistantId = default; - string runId = default; - IReadOnlyList attachments = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("thread_id"u8)) - { - threadId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new MessageStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("incomplete_details"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - incompleteDetails = null; - continue; - } - incompleteDetails = MessageIncompleteDetails.DeserializeMessageIncompleteDetails(property.Value, options); - continue; - } - if (property.NameEquals("completed_at"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - completedAt = null; - continue; - } - completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("incomplete_at"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - incompleteAt = null; - continue; - } - incompleteAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("role"u8)) - { - role = new MessageRole(property.Value.GetString()); - continue; - } - if (property.NameEquals("content"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageContent.DeserializeMessageContent(item, options)); - } - content = array; - continue; - } - if (property.NameEquals("assistant_id"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - assistantId = null; - continue; - } - assistantId = property.Value.GetString(); - continue; - } - if (property.NameEquals("run_id"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - runId = null; - continue; - } - runId = property.Value.GetString(); - continue; - } - if (property.NameEquals("attachments"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - attachments = new ChangeTrackingList(); - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageAttachment.DeserializeMessageAttachment(item, options)); - } - attachments = array; - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ThreadMessage( - id, - @object, - createdAt, - threadId, - status, - incompleteDetails, - completedAt, - incompleteAt, - role, - content, - assistantId, - runId, - attachments, - metadata, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ThreadMessage)} does not support writing '{options.Format}' format."); - } - } - - ThreadMessage 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 DeserializeThreadMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ThreadMessage)} 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 ThreadMessage FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeThreadMessage(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/ThreadMessage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessage.cs deleted file mode 100644 index e5adfbbe605a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessage.cs +++ /dev/null @@ -1,165 +0,0 @@ -// 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 single, existing message within an agent thread. - public partial class ThreadMessage - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The ID of the thread that this message belongs to. - /// The status of the message. - /// On an incomplete message, details about why the message is incomplete. - /// The Unix timestamp (in seconds) for when the message was completed. - /// The Unix timestamp (in seconds) for when the message was marked as incomplete. - /// The role associated with the agent thread message. - /// - /// The list of content items associated with the agent thread message. - /// 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 . - /// - /// If applicable, the ID of the agent that authored this message. - /// If applicable, the ID of the run associated with the authoring of this message. - /// A list of files attached to the message, and the tools they were added to. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// , or is null. - internal ThreadMessage(string id, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageIncompleteDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IEnumerable contentItems, string assistantId, string runId, IEnumerable attachments, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(threadId, nameof(threadId)); - Argument.AssertNotNull(contentItems, nameof(contentItems)); - - Id = id; - CreatedAt = createdAt; - ThreadId = threadId; - Status = status; - IncompleteDetails = incompleteDetails; - CompletedAt = completedAt; - IncompleteAt = incompleteAt; - Role = role; - ContentItems = contentItems.ToList(); - AssistantId = assistantId; - RunId = runId; - Attachments = attachments?.ToList(); - Metadata = metadata; - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always 'thread.message'. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The ID of the thread that this message belongs to. - /// The status of the message. - /// On an incomplete message, details about why the message is incomplete. - /// The Unix timestamp (in seconds) for when the message was completed. - /// The Unix timestamp (in seconds) for when the message was marked as incomplete. - /// The role associated with the agent thread message. - /// - /// The list of content items associated with the agent thread message. - /// 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 . - /// - /// If applicable, the ID of the agent that authored this message. - /// If applicable, the ID of the run associated with the authoring of this message. - /// A list of files attached to the message, and the tools they were added to. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal ThreadMessage(string id, string @object, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageIncompleteDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IReadOnlyList contentItems, string assistantId, string runId, IReadOnlyList attachments, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - ThreadId = threadId; - Status = status; - IncompleteDetails = incompleteDetails; - CompletedAt = completedAt; - IncompleteAt = incompleteAt; - Role = role; - ContentItems = contentItems; - AssistantId = assistantId; - RunId = runId; - Attachments = attachments; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ThreadMessage() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - - /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } - /// The ID of the thread that this message belongs to. - public string ThreadId { get; } - /// The status of the message. - public MessageStatus Status { get; } - /// On an incomplete message, details about why the message is incomplete. - public MessageIncompleteDetails IncompleteDetails { get; } - /// The Unix timestamp (in seconds) for when the message was completed. - public DateTimeOffset? CompletedAt { get; } - /// The Unix timestamp (in seconds) for when the message was marked as incomplete. - public DateTimeOffset? IncompleteAt { get; } - /// The role associated with the agent thread message. - public MessageRole Role { get; } - /// - /// The list of content items associated with the agent thread message. - /// 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 IReadOnlyList ContentItems { get; } - /// If applicable, the ID of the agent that authored this message. - public string AssistantId { get; } - /// If applicable, the ID of the run associated with the authoring of this message. - public string RunId { get; } - /// A list of files attached to the message, and the tools they were added to. - public IReadOnlyList Attachments { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.Serialization.cs deleted file mode 100644 index 41f9b5ab06e4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.Serialization.cs +++ /dev/null @@ -1,222 +0,0 @@ -// 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 ThreadMessageOptions : 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(ThreadMessageOptions)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToString()); - writer.WritePropertyName("content"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Content); -#else - using (JsonDocument document = JsonDocument.Parse(Content, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - if (Optional.IsCollectionDefined(Attachments)) - { - if (Attachments != null) - { - writer.WritePropertyName("attachments"u8); - writer.WriteStartArray(); - foreach (var item in Attachments) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("attachments"); - } - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - ThreadMessageOptions 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(ThreadMessageOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadMessageOptions(document.RootElement, options); - } - - internal static ThreadMessageOptions DeserializeThreadMessageOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageRole role = default; - BinaryData content = default; - IList attachments = default; - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("role"u8)) - { - role = new MessageRole(property.Value.GetString()); - continue; - } - if (property.NameEquals("content"u8)) - { - content = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("attachments"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageAttachment.DeserializeMessageAttachment(item, options)); - } - attachments = array; - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ThreadMessageOptions(role, content, attachments ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support writing '{options.Format}' format."); - } - } - - ThreadMessageOptions 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 DeserializeThreadMessageOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ThreadMessageOptions)} 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 ThreadMessageOptions FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeThreadMessageOptions(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/ThreadMessageOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.cs deleted file mode 100644 index 4a6ca018b978..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.cs +++ /dev/null @@ -1,162 +0,0 @@ -// 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 single message within an agent thread, - /// as provided during that thread's creation for its initial state. - /// - public partial class ThreadMessageOptions - { - /// - /// 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 role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). - /// - /// is null. - public ThreadMessageOptions(MessageRole role, BinaryData content) - { - Argument.AssertNotNull(content, nameof(content)); - - Role = role; - Content = content; - Attachments = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// - /// The role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). - /// - /// A list of files attached to the message, and the tools they should be added to. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal ThreadMessageOptions(MessageRole role, BinaryData content, IList attachments, IDictionary metadata, IDictionary serializedAdditionalRawData) - { - Role = role; - Content = content; - Attachments = attachments; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ThreadMessageOptions() - { - } - - /// - /// The role of the entity that is creating the message. Allowed values include: - /// `user`, which indicates the message is sent by an actual user (and should be - /// used in most cases to represent user-generated messages), and `assistant`, - /// which indicates the message is generated by the agent (use this value to insert - /// messages from the agent into the conversation). - /// - public MessageRole Role { get; } - /// - /// The content of the initial message. This may be a basic string (if you only - /// need text) or an array of typed content blocks (for example, text, image_file, - /// image_url, and so on). - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// where T is of type - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Content { get; } - /// A list of files attached to the message, and the tools they should be added to. - public IList Attachments { get; set; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IDictionary Metadata { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.Serialization.cs deleted file mode 100644 index 6c090fa42b46..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.Serialization.cs +++ /dev/null @@ -1,625 +0,0 @@ -// 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 ThreadRun : 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(ThreadRun)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object); - writer.WritePropertyName("thread_id"u8); - writer.WriteStringValue(ThreadId); - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); - if (Optional.IsDefined(RequiredAction)) - { - if (RequiredAction != null) - { - writer.WritePropertyName("required_action"u8); - writer.WriteObjectValue(RequiredAction, options); - } - else - { - writer.WriteNull("required_action"); - } - } - if (LastError != null) - { - writer.WritePropertyName("last_error"u8); - writer.WriteObjectValue(LastError, options); - } - else - { - writer.WriteNull("last_error"); - } - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - if (ExpiresAt != null) - { - writer.WritePropertyName("expires_at"u8); - writer.WriteNumberValue(ExpiresAt.Value, "U"); - } - else - { - writer.WriteNull("expires_at"); - } - if (StartedAt != null) - { - writer.WritePropertyName("started_at"u8); - writer.WriteNumberValue(StartedAt.Value, "U"); - } - else - { - writer.WriteNull("started_at"); - } - if (CompletedAt != null) - { - writer.WritePropertyName("completed_at"u8); - writer.WriteNumberValue(CompletedAt.Value, "U"); - } - else - { - writer.WriteNull("completed_at"); - } - if (CancelledAt != null) - { - writer.WritePropertyName("cancelled_at"u8); - writer.WriteNumberValue(CancelledAt.Value, "U"); - } - else - { - writer.WriteNull("cancelled_at"); - } - if (FailedAt != null) - { - writer.WritePropertyName("failed_at"u8); - writer.WriteNumberValue(FailedAt.Value, "U"); - } - else - { - writer.WriteNull("failed_at"); - } - if (IncompleteDetails != null) - { - writer.WritePropertyName("incomplete_details"u8); - writer.WriteObjectValue(IncompleteDetails, options); - } - else - { - writer.WriteNull("incomplete_details"); - } - if (Usage != null) - { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); - } - else - { - writer.WriteNull("usage"); - } - if (Optional.IsDefined(Temperature)) - { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } - } - if (Optional.IsDefined(TopP)) - { - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } - } - if (MaxPromptTokens != null) - { - writer.WritePropertyName("max_prompt_tokens"u8); - writer.WriteNumberValue(MaxPromptTokens.Value); - } - else - { - writer.WriteNull("max_prompt_tokens"); - } - if (MaxCompletionTokens != null) - { - writer.WritePropertyName("max_completion_tokens"u8); - writer.WriteNumberValue(MaxCompletionTokens.Value); - } - else - { - writer.WriteNull("max_completion_tokens"); - } - if (TruncationStrategy != null) - { - writer.WritePropertyName("truncation_strategy"u8); - writer.WriteObjectValue(TruncationStrategy, options); - } - else - { - writer.WriteNull("truncation_strategy"); - } - if (ToolChoice != null) - { - writer.WritePropertyName("tool_choice"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ToolChoice); -#else - using (JsonDocument document = JsonDocument.Parse(ToolChoice, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("tool_choice"); - } - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ResponseFormat); -#else - using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("response_format"); - } - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - if (Optional.IsDefined(ToolResources)) - { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } - } - writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(ParallelToolCalls); - 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 - } - } - } - - ThreadRun 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(ThreadRun)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadRun(document.RootElement, options); - } - - internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - string @object = default; - string threadId = default; - string assistantId = default; - RunStatus status = default; - RequiredAction requiredAction = default; - RunError lastError = default; - string model = default; - string instructions = default; - IReadOnlyList tools = default; - DateTimeOffset createdAt = default; - DateTimeOffset? expiresAt = default; - DateTimeOffset? startedAt = default; - DateTimeOffset? completedAt = default; - DateTimeOffset? cancelledAt = default; - DateTimeOffset? failedAt = default; - IncompleteRunDetails incompleteDetails = default; - RunCompletionUsage usage = default; - float? temperature = default; - float? topP = default; - int? maxPromptTokens = default; - int? maxCompletionTokens = default; - TruncationObject truncationStrategy = default; - BinaryData toolChoice = default; - BinaryData responseFormat = default; - IReadOnlyDictionary metadata = default; - UpdateToolResourcesOptions toolResources = default; - bool parallelToolCalls = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = property.Value.GetString(); - continue; - } - if (property.NameEquals("thread_id"u8)) - { - threadId = property.Value.GetString(); - continue; - } - if (property.NameEquals("assistant_id"u8)) - { - assistantId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new RunStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("required_action"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - requiredAction = null; - continue; - } - requiredAction = RequiredAction.DeserializeRequiredAction(property.Value, options); - continue; - } - if (property.NameEquals("last_error"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastError = null; - continue; - } - lastError = RunError.DeserializeRunError(property.Value, options); - continue; - } - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("instructions"u8)) - { - instructions = property.Value.GetString(); - continue; - } - if (property.NameEquals("tools"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("expires_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref expiresAt); - continue; - } - if (property.NameEquals("started_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref startedAt); - continue; - } - if (property.NameEquals("completed_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref completedAt); - continue; - } - if (property.NameEquals("cancelled_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref cancelledAt); - continue; - } - if (property.NameEquals("failed_at"u8)) - { - DeserializeNullableDateTimeOffset(property, ref failedAt); - continue; - } - if (property.NameEquals("incomplete_details"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - incompleteDetails = null; - continue; - } - incompleteDetails = IncompleteRunDetails.DeserializeIncompleteRunDetails(property.Value, options); - continue; - } - if (property.NameEquals("usage"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - usage = null; - continue; - } - usage = RunCompletionUsage.DeserializeRunCompletionUsage(property.Value, options); - continue; - } - if (property.NameEquals("temperature"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("top_p"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("max_prompt_tokens"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxPromptTokens = null; - continue; - } - maxPromptTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("max_completion_tokens"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxCompletionTokens = null; - continue; - } - maxCompletionTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("truncation_strategy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - truncationStrategy = null; - continue; - } - truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); - continue; - } - if (property.NameEquals("tool_choice"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolChoice = null; - continue; - } - toolChoice = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("response_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (property.NameEquals("tool_resources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = UpdateToolResourcesOptions.DeserializeUpdateToolResourcesOptions(property.Value, options); - continue; - } - if (property.NameEquals("parallel_tool_calls"u8)) - { - parallelToolCalls = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ThreadRun( - id, - @object, - threadId, - assistantId, - status, - requiredAction, - lastError, - model, - instructions, - tools, - createdAt, - expiresAt, - startedAt, - completedAt, - cancelledAt, - failedAt, - incompleteDetails, - usage, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - responseFormat, - metadata, - toolResources, - parallelToolCalls, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ThreadRun)} does not support writing '{options.Format}' format."); - } - } - - ThreadRun 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 DeserializeThreadRun(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ThreadRun)} 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 ThreadRun FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeThreadRun(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/ThreadRun.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.cs deleted file mode 100644 index 3fd2e5179862..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.cs +++ /dev/null @@ -1,341 +0,0 @@ -// 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 -{ - /// Data representing a single evaluation run of an agent thread. - public partial class ThreadRun - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// The ID of the thread associated with this run. - /// The ID of the agent associated with the thread this run was performed against. - /// The status of the agent thread run. - /// The last error, if any, encountered by this agent thread run. - /// The ID of the model to use. - /// The overridden system instructions used for this agent thread run. - /// - /// 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 Unix timestamp, in seconds, representing when this object was created. - /// The Unix timestamp, in seconds, representing when this item expires. - /// The Unix timestamp, in seconds, representing when this item was started. - /// The Unix timestamp, in seconds, representing when this completed. - /// The Unix timestamp, in seconds, representing when this was cancelled. - /// The Unix timestamp, in seconds, representing when this failed. - /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. - /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - /// The maximum number of prompt tokens specified to have been used over the course of the run. - /// The maximum number of completion tokens specified to have been used over the course of the run. - /// The strategy to use for dropping messages as the context windows moves forward. - /// Controls whether or not and which tool is called by the model. - /// The response format of the tool calls used in this run. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Determines if tools can be executed in parallel within the run. - /// , , , , or is null. - internal ThreadRun(string id, string threadId, string assistantId, RunStatus status, RunError lastError, string model, string instructions, IEnumerable tools, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IncompleteRunDetails incompleteDetails, RunCompletionUsage usage, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, IReadOnlyDictionary metadata, bool parallelToolCalls) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(threadId, nameof(threadId)); - Argument.AssertNotNull(assistantId, nameof(assistantId)); - Argument.AssertNotNull(model, nameof(model)); - Argument.AssertNotNull(instructions, nameof(instructions)); - Argument.AssertNotNull(tools, nameof(tools)); - - Id = id; - ThreadId = threadId; - AssistantId = assistantId; - Status = status; - LastError = lastError; - Model = model; - Instructions = instructions; - Tools = tools.ToList(); - CreatedAt = createdAt; - ExpiresAt = expiresAt; - StartedAt = startedAt; - CompletedAt = completedAt; - CancelledAt = cancelledAt; - FailedAt = failedAt; - IncompleteDetails = incompleteDetails; - Usage = usage; - MaxPromptTokens = maxPromptTokens; - MaxCompletionTokens = maxCompletionTokens; - TruncationStrategy = truncationStrategy; - ToolChoice = toolChoice; - ResponseFormat = responseFormat; - Metadata = metadata; - ParallelToolCalls = parallelToolCalls; - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always 'thread.run'. - /// The ID of the thread associated with this run. - /// The ID of the agent associated with the thread this run was performed against. - /// The status of the agent thread run. - /// - /// The details of the action required for the agent thread run to continue. - /// 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 . - /// - /// The last error, if any, encountered by this agent thread run. - /// The ID of the model to use. - /// The overridden system instructions used for this agent thread run. - /// - /// 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 Unix timestamp, in seconds, representing when this object was created. - /// The Unix timestamp, in seconds, representing when this item expires. - /// The Unix timestamp, in seconds, representing when this item was started. - /// The Unix timestamp, in seconds, representing when this completed. - /// The Unix timestamp, in seconds, representing when this was cancelled. - /// The Unix timestamp, in seconds, representing when this failed. - /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. - /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - /// The sampling temperature used for this run. If not set, defaults to 1. - /// The nucleus sampling value used for this run. If not set, defaults to 1. - /// The maximum number of prompt tokens specified to have been used over the course of the run. - /// The maximum number of completion tokens specified to have been used over the course of the run. - /// The strategy to use for dropping messages as the context windows moves forward. - /// Controls whether or not and which tool is called by the model. - /// The response format of the tool calls used in this run. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. - /// Determines if tools can be executed in parallel within the run. - /// Keeps track of any properties unknown to the library. - internal ThreadRun(string id, string @object, string threadId, string assistantId, RunStatus status, RequiredAction requiredAction, RunError lastError, string model, string instructions, IReadOnlyList tools, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IncompleteRunDetails incompleteDetails, RunCompletionUsage usage, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, IReadOnlyDictionary metadata, UpdateToolResourcesOptions toolResources, bool parallelToolCalls, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - ThreadId = threadId; - AssistantId = assistantId; - Status = status; - RequiredAction = requiredAction; - LastError = lastError; - Model = model; - Instructions = instructions; - Tools = tools; - CreatedAt = createdAt; - ExpiresAt = expiresAt; - StartedAt = startedAt; - CompletedAt = completedAt; - CancelledAt = cancelledAt; - FailedAt = failedAt; - IncompleteDetails = incompleteDetails; - Usage = usage; - Temperature = temperature; - TopP = topP; - MaxPromptTokens = maxPromptTokens; - MaxCompletionTokens = maxCompletionTokens; - TruncationStrategy = truncationStrategy; - ToolChoice = toolChoice; - ResponseFormat = responseFormat; - Metadata = metadata; - ToolResources = toolResources; - ParallelToolCalls = parallelToolCalls; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ThreadRun() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - - /// The ID of the thread associated with this run. - public string ThreadId { get; } - /// The ID of the agent associated with the thread this run was performed against. - public string AssistantId { get; } - /// The status of the agent thread run. - public RunStatus Status { get; } - /// - /// The details of the action required for the agent thread run to continue. - /// 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 . - /// - public RequiredAction RequiredAction { get; } - /// The last error, if any, encountered by this agent thread run. - public RunError LastError { get; } - /// The ID of the model to use. - public string Model { get; } - /// The overridden system instructions used for this agent thread run. - public string Instructions { get; } - /// - /// 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 . - /// - public IReadOnlyList Tools { get; } - /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } - /// The Unix timestamp, in seconds, representing when this item expires. - public DateTimeOffset? ExpiresAt { get; } - /// The Unix timestamp, in seconds, representing when this item was started. - public DateTimeOffset? StartedAt { get; } - /// The Unix timestamp, in seconds, representing when this completed. - public DateTimeOffset? CompletedAt { get; } - /// The Unix timestamp, in seconds, representing when this was cancelled. - public DateTimeOffset? CancelledAt { get; } - /// The Unix timestamp, in seconds, representing when this failed. - public DateTimeOffset? FailedAt { get; } - /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. - public IncompleteRunDetails IncompleteDetails { get; } - /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - public RunCompletionUsage Usage { get; } - /// The sampling temperature used for this run. If not set, defaults to 1. - public float? Temperature { get; } - /// The nucleus sampling value used for this run. If not set, defaults to 1. - public float? TopP { get; } - /// The maximum number of prompt tokens specified to have been used over the course of the run. - public int? MaxPromptTokens { get; } - /// The maximum number of completion tokens specified to have been used over the course of the run. - public int? MaxCompletionTokens { get; } - /// The strategy to use for dropping messages as the context windows moves forward. - public TruncationObject TruncationStrategy { get; } - /// - /// Controls whether or not and which tool is called by the model. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ToolChoice { get; } - /// - /// The response format of the tool calls used in this run. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ResponseFormat { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. - public UpdateToolResourcesOptions ToolResources { get; } - /// Determines if tools can be executed in parallel within the run. - public bool ParallelToolCalls { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadStreamEvent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadStreamEvent.cs deleted file mode 100644 index 446ffec4a4b9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadStreamEvent.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Thread operation related streaming events. - public readonly partial struct ThreadStreamEvent : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public ThreadStreamEvent(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ThreadCreatedValue = "thread.created"; - - /// Event sent when a new thread is created. The data of this event is of type AgentThread. - public static ThreadStreamEvent ThreadCreated { get; } = new ThreadStreamEvent(ThreadCreatedValue); - /// Determines if two values are the same. - public static bool operator ==(ThreadStreamEvent left, ThreadStreamEvent right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(ThreadStreamEvent left, ThreadStreamEvent right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator ThreadStreamEvent(string value) => new ThreadStreamEvent(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ThreadStreamEvent other && Equals(other); - /// - public bool Equals(ThreadStreamEvent 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/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnection.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnection.Serialization.cs deleted file mode 100644 index d0cbb7c9a912..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnection.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 ToolConnection : 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(ToolConnection)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("connection_id"u8); - writer.WriteStringValue(ConnectionId); - 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 - } - } - } - - ToolConnection 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(ToolConnection)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolConnection(document.RootElement, options); - } - - internal static ToolConnection DeserializeToolConnection(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string connectionId = 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 (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ToolConnection(connectionId, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ToolConnection)} does not support writing '{options.Format}' format."); - } - } - - ToolConnection 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 DeserializeToolConnection(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolConnection)} 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 ToolConnection FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeToolConnection(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/ToolConnection.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnection.cs deleted file mode 100644 index d60e6fe9ab5b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnection.cs +++ /dev/null @@ -1,75 +0,0 @@ -// 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 connection resource. - public partial class ToolConnection - { - /// - /// 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. - /// is null. - public ToolConnection(string connectionId) - { - Argument.AssertNotNull(connectionId, nameof(connectionId)); - - ConnectionId = connectionId; - } - - /// Initializes a new instance of . - /// A connection in a ToolConnectionList attached to this tool. - /// Keeps track of any properties unknown to the library. - internal ToolConnection(string connectionId, IDictionary serializedAdditionalRawData) - { - ConnectionId = connectionId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ToolConnection() - { - } - - /// A connection in a ToolConnectionList attached to this tool. - public string ConnectionId { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnectionList.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnectionList.Serialization.cs deleted file mode 100644 index 89f3336bd673..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnectionList.Serialization.cs +++ /dev/null @@ -1,159 +0,0 @@ -// 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 ToolConnectionList : 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(ToolConnectionList)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(ConnectionList)) - { - writer.WritePropertyName("connections"u8); - writer.WriteStartArray(); - foreach (var item in ConnectionList) - { - 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 - } - } - } - - ToolConnectionList 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(ToolConnectionList)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolConnectionList(document.RootElement, options); - } - - internal static ToolConnectionList DeserializeToolConnectionList(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList connections = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("connections"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolConnection.DeserializeToolConnection(item, options)); - } - connections = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ToolConnectionList(connections ?? 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ToolConnectionList)} does not support writing '{options.Format}' format."); - } - } - - ToolConnectionList 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 DeserializeToolConnectionList(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolConnectionList)} 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 ToolConnectionList FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeToolConnectionList(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/ToolConnectionList.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnectionList.cs deleted file mode 100644 index d243e2198c2d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolConnectionList.cs +++ /dev/null @@ -1,72 +0,0 @@ -// 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 set of connection resources currently used by either the `bing_grounding`, `fabric_dataagent`, or `sharepoint_grounding` tools. - public partial class ToolConnectionList - { - /// - /// 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 . - public ToolConnectionList() - { - ConnectionList = new ChangeTrackingList(); - } - - /// 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 ToolConnectionList(IList connectionList, IDictionary serializedAdditionalRawData) - { - ConnectionList = connectionList; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// The connections attached to this tool. There can be a maximum of 1 connection - /// resource attached to the tool. - /// - public IList ConnectionList { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.Serialization.cs deleted file mode 100644 index 4b888a0343b0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.Serialization.cs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownToolDefinition))] - public partial class ToolDefinition : 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(ToolDefinition)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - ToolDefinition 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(ToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolDefinition(document.RootElement, options); - } - - internal static ToolDefinition DeserializeToolDefinition(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_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 "connected_agent": return ConnectedAgentToolDefinition.DeserializeConnectedAgentToolDefinition(element, options); - case "fabric_dataagent": return MicrosoftFabricToolDefinition.DeserializeMicrosoftFabricToolDefinition(element, options); - case "file_search": return FileSearchToolDefinition.DeserializeFileSearchToolDefinition(element, options); - case "function": return FunctionToolDefinition.DeserializeFunctionToolDefinition(element, options); - case "openapi": return OpenApiToolDefinition.DeserializeOpenApiToolDefinition(element, options); - case "sharepoint_grounding": return SharepointToolDefinition.DeserializeSharepointToolDefinition(element, options); - } - } - return UnknownToolDefinition.DeserializeUnknownToolDefinition(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - ToolDefinition 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 DeserializeToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolDefinition)} 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 ToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeToolDefinition(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/ToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.cs deleted file mode 100644 index 5478a0486917..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -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 . - /// - public abstract partial class ToolDefinition - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected ToolDefinition() - { - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal ToolDefinition(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The object type. - internal string Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolOutput.Serialization.cs deleted file mode 100644 index 261162ecfe0e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolOutput.Serialization.cs +++ /dev/null @@ -1,156 +0,0 @@ -// 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 ToolOutput : 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(ToolOutput)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(ToolCallId)) - { - writer.WritePropertyName("tool_call_id"u8); - writer.WriteStringValue(ToolCallId); - } - if (Optional.IsDefined(Output)) - { - writer.WritePropertyName("output"u8); - writer.WriteStringValue(Output); - } - 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 - } - } - } - - ToolOutput 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(ToolOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolOutput(document.RootElement, options); - } - - internal static ToolOutput DeserializeToolOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string toolCallId = default; - string output = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("tool_call_id"u8)) - { - toolCallId = property.Value.GetString(); - continue; - } - if (property.NameEquals("output"u8)) - { - output = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ToolOutput(toolCallId, output, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ToolOutput)} does not support writing '{options.Format}' format."); - } - } - - ToolOutput 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 DeserializeToolOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolOutput)} 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 ToolOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeToolOutput(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/ToolResources.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolResources.Serialization.cs deleted file mode 100644 index c4619ba84da1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolResources.Serialization.cs +++ /dev/null @@ -1,179 +0,0 @@ -// 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 ToolResources : 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(ToolResources)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (Optional.IsDefined(AzureAISearch)) - { - writer.WritePropertyName("azure_ai_search"u8); - writer.WriteObjectValue(AzureAISearch, options); - } - 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 - } - } - } - - ToolResources 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(ToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolResources(document.RootElement, options); - } - - internal static ToolResources DeserializeToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - CodeInterpreterToolResource codeInterpreter = default; - FileSearchToolResource fileSearch = default; - AzureAISearchResource azureAiSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code_interpreter"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = CodeInterpreterToolResource.DeserializeCodeInterpreterToolResource(property.Value, options); - continue; - } - if (property.NameEquals("file_search"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = FileSearchToolResource.DeserializeFileSearchToolResource(property.Value, options); - continue; - } - if (property.NameEquals("azure_ai_search"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - azureAiSearch = AzureAISearchResource.DeserializeAzureAISearchResource(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ToolResources(codeInterpreter, fileSearch, azureAiSearch, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{options.Format}' format."); - } - } - - ToolResources 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 DeserializeToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolResources)} 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 ToolResources FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeToolResources(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/ToolResources.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolResources.cs deleted file mode 100644 index f3bc125c78b5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolResources.cs +++ /dev/null @@ -1,77 +0,0 @@ -// 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 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` tool requires a list of file IDs, while the `file_search` - /// tool requires a list of vector store IDs. - /// - public partial class ToolResources - { - /// - /// 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 . - public ToolResources() - { - } - - /// Initializes a new instance of . - /// Resources to be used by the `code_interpreter` tool consisting of file IDs. - /// Resources to be used by the `file_search` tool consisting of vector store IDs. - /// Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. - /// Keeps track of any properties unknown to the library. - internal ToolResources(CodeInterpreterToolResource codeInterpreter, FileSearchToolResource fileSearch, AzureAISearchResource azureAISearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - AzureAISearch = azureAISearch; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Resources to be used by the `code_interpreter` tool consisting of file IDs. - public CodeInterpreterToolResource CodeInterpreter { get; set; } - /// Resources to be used by the `file_search` tool consisting of vector store IDs. - public FileSearchToolResource FileSearch { get; set; } - /// Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. - public AzureAISearchResource AzureAISearch { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.Serialization.cs deleted file mode 100644 index 36c2fdd6b616..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownTrigger))] - public partial class Trigger : 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(Trigger)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - 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 - } - } - } - - Trigger 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(Trigger)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTrigger(document.RootElement, options); - } - - internal static Trigger DeserializeTrigger(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 "Cron": return CronTrigger.DeserializeCronTrigger(element, options); - case "Recurrence": return RecurrenceTrigger.DeserializeRecurrenceTrigger(element, options); - } - } - return UnknownTrigger.DeserializeUnknownTrigger(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(Trigger)} does not support writing '{options.Format}' format."); - } - } - - Trigger 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 DeserializeTrigger(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Trigger)} 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 Trigger FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrigger(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/Trigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.cs deleted file mode 100644 index 7b792ec9f5a0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// Abstract data class for input data configuration. - /// 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 Trigger - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected Trigger() - { - } - - /// Initializes a new instance of . - /// Type of the trigger. - /// Keeps track of any properties unknown to the library. - internal Trigger(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Type of the trigger. - internal string Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TruncationObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TruncationObject.Serialization.cs deleted file mode 100644 index 2f319968776e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/TruncationObject.Serialization.cs +++ /dev/null @@ -1,165 +0,0 @@ -// 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 TruncationObject : 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(TruncationObject)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - if (Optional.IsDefined(LastMessages)) - { - if (LastMessages != null) - { - writer.WritePropertyName("last_messages"u8); - writer.WriteNumberValue(LastMessages.Value); - } - else - { - writer.WriteNull("last_messages"); - } - } - 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 - } - } - } - - TruncationObject 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(TruncationObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTruncationObject(document.RootElement, options); - } - - internal static TruncationObject DeserializeTruncationObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - TruncationStrategy type = default; - int? lastMessages = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new TruncationStrategy(property.Value.GetString()); - continue; - } - if (property.NameEquals("last_messages"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastMessages = null; - continue; - } - lastMessages = property.Value.GetInt32(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new TruncationObject(type, lastMessages, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(TruncationObject)} does not support writing '{options.Format}' format."); - } - } - - TruncationObject 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 DeserializeTruncationObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TruncationObject)} 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 TruncationObject FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTruncationObject(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/TruncationObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TruncationObject.cs deleted file mode 100644 index 679d27cf6b22..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/TruncationObject.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// Controls for how a thread will be truncated prior to the run. Use this to control the initial - /// context window of the run. - /// - public partial class TruncationObject - { - /// - /// 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 truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will - /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread - /// will be dropped to fit the context length of the model, `max_prompt_tokens`. - /// - public TruncationObject(TruncationStrategy type) - { - Type = type; - } - - /// Initializes a new instance of . - /// - /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will - /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread - /// will be dropped to fit the context length of the model, `max_prompt_tokens`. - /// - /// The number of most recent messages from the thread when constructing the context for the run. - /// Keeps track of any properties unknown to the library. - internal TruncationObject(TruncationStrategy type, int? lastMessages, IDictionary serializedAdditionalRawData) - { - Type = type; - LastMessages = lastMessages; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TruncationObject() - { - } - - /// - /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will - /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread - /// will be dropped to fit the context length of the model, `max_prompt_tokens`. - /// - public TruncationStrategy Type { get; set; } - /// The number of most recent messages from the thread when constructing the context for the run. - public int? LastMessages { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TruncationStrategy.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TruncationStrategy.cs deleted file mode 100644 index cb56b0f81c9d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/TruncationStrategy.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Possible truncation strategies for the thread. - public readonly partial struct TruncationStrategy : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public TruncationStrategy(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string LastMessagesValue = "last_messages"; - - /// Default value. Messages in the middle of the thread will be dropped to fit the context length of the model. - public static TruncationStrategy Auto { get; } = new TruncationStrategy(AutoValue); - /// The thread will truncate to the `lastMessages` count of recent messages. - public static TruncationStrategy LastMessages { get; } = new TruncationStrategy(LastMessagesValue); - /// Determines if two values are the same. - public static bool operator ==(TruncationStrategy left, TruncationStrategy right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(TruncationStrategy left, TruncationStrategy right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator TruncationStrategy(string value) => new TruncationStrategy(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is TruncationStrategy other && Equals(other); - /// - public bool Equals(TruncationStrategy 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/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownBaseCredentials.Serialization.cs similarity index 66% rename from sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepToolCall.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/UnknownBaseCredentials.Serialization.cs index 706b5ab161a8..7a5509679b2f 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepToolCall.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownBaseCredentials.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class UnknownRunStepToolCall : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownBaseCredentials : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,28 +28,28 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(BaseCredentials)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); } - RunStepToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + BaseCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(BaseCredentials)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepToolCall(document.RootElement, options); + return DeserializeBaseCredentials(document.RootElement, options); } - internal static UnknownRunStepToolCall DeserializeUnknownRunStepToolCall(JsonElement element, ModelReaderWriterOptions options = null) + internal static UnknownBaseCredentials DeserializeUnknownBaseCredentials(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -57,20 +57,14 @@ internal static UnknownRunStepToolCall DeserializeUnknownRunStepToolCall(JsonEle { return null; } - string type = "Unknown"; - string id = default; + CredentialType type = "Unknown"; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); + type = new CredentialType(property.Value.GetString()); continue; } if (options.Format != "W") @@ -79,53 +73,53 @@ internal static UnknownRunStepToolCall DeserializeUnknownRunStepToolCall(JsonEle } } serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepToolCall(type, id, serializedAdditionalRawData); + return new UnknownBaseCredentials(type, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(BaseCredentials)} does not support writing '{options.Format}' format."); } } - RunStepToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + BaseCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepToolCall(document.RootElement, options); + return DeserializeBaseCredentials(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(BaseCredentials)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new UnknownRunStepToolCall FromResponse(Response response) + internal static new UnknownBaseCredentials FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownRunStepToolCall(document.RootElement); + return DeserializeUnknownBaseCredentials(document.RootElement); } /// Convert into a . internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownBaseCredentials.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownBaseCredentials.cs new file mode 100644 index 000000000000..02b7669e09b3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownBaseCredentials.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Unknown version of BaseCredentials. + internal partial class UnknownBaseCredentials : BaseCredentials + { + /// Initializes a new instance of . + /// The type of credential used by the connection. + /// Keeps track of any properties unknown to the library. + internal UnknownBaseCredentials(CredentialType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownBaseCredentials() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDatasetVersion.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDatasetVersion.Serialization.cs new file mode 100644 index 000000000000..7b57c282c9b1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDatasetVersion.Serialization.cs @@ -0,0 +1,197 @@ +// 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 +{ + internal partial class UnknownDatasetVersion : 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(DatasetVersion)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + DatasetVersion 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(DatasetVersion)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDatasetVersion(document.RootElement, options); + } + + internal static UnknownDatasetVersion DeserializeUnknownDatasetVersion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string dataUri = default; + DatasetType type = "Unknown"; + bool? isReference = default; + string connectionName = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dataUri"u8)) + { + dataUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new DatasetType(property.Value.GetString()); + continue; + } + if (property.NameEquals("isReference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isReference = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownDatasetVersion( + dataUri, + type, + isReference, + connectionName, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + 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, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(DatasetVersion)} does not support writing '{options.Format}' format."); + } + } + + DatasetVersion 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 DeserializeDatasetVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DatasetVersion)} 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 UnknownDatasetVersion FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownDatasetVersion(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/UnknownDatasetVersion.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDatasetVersion.cs new file mode 100644 index 000000000000..7a018a5bee51 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDatasetVersion.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Unknown version of DatasetVersion. + internal partial class UnknownDatasetVersion : DatasetVersion + { + /// Initializes a new instance of . + /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. + /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal UnknownDatasetVersion(string dataUri, DatasetType type, bool? isReference, string connectionName, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) : base(dataUri, type, isReference, connectionName, id, name, version, description, tags, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownDatasetVersion() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDeployment.Serialization.cs similarity index 60% rename from sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredAction.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/UnknownDeployment.Serialization.cs index b658d25291e0..4370d0518438 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredAction.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDeployment.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class UnknownRequiredAction : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownDeployment : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,28 +28,28 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RequiredAction)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(Deployment)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); } - RequiredAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + Deployment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RequiredAction)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(Deployment)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRequiredAction(document.RootElement, options); + return DeserializeDeployment(document.RootElement, options); } - internal static UnknownRequiredAction DeserializeUnknownRequiredAction(JsonElement element, ModelReaderWriterOptions options = null) + internal static UnknownDeployment DeserializeUnknownDeployment(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -57,14 +57,20 @@ internal static UnknownRequiredAction DeserializeUnknownRequiredAction(JsonEleme { return null; } - string type = "Unknown"; + DeploymentType type = "Unknown"; + string name = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) { - type = property.Value.GetString(); + type = new DeploymentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); continue; } if (options.Format != "W") @@ -73,53 +79,53 @@ internal static UnknownRequiredAction DeserializeUnknownRequiredAction(JsonEleme } } serializedAdditionalRawData = rawDataDictionary; - return new UnknownRequiredAction(type, serializedAdditionalRawData); + return new UnknownDeployment(type, name, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RequiredAction)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(Deployment)} does not support writing '{options.Format}' format."); } } - RequiredAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + Deployment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRequiredAction(document.RootElement, options); + return DeserializeDeployment(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RequiredAction)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(Deployment)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new UnknownRequiredAction FromResponse(Response response) + internal static new UnknownDeployment FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownRequiredAction(document.RootElement); + return DeserializeUnknownDeployment(document.RootElement); } /// Convert into a . internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDeployment.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDeployment.cs new file mode 100644 index 000000000000..9d07b4059cf6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownDeployment.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Unknown version of Deployment. + internal partial class UnknownDeployment : Deployment + { + /// Initializes a new instance of . + /// The type of the deployment. + /// Name of the deployment. + /// Keeps track of any properties unknown to the library. + internal UnknownDeployment(DeploymentType type, string name, IDictionary serializedAdditionalRawData) : base(type, name, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownDeployment() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownIndex.Serialization.cs similarity index 55% rename from sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/UnknownIndex.Serialization.cs index e4e0edaa8412..8fc4c5123304 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownIndex.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - public partial class RunStepCustomSearchToolCall : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownIndex : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,36 +28,28 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// 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; + 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."); + throw new FormatException($"The model {nameof(Index)} 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) + Index IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + 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."); + throw new FormatException($"The model {nameof(Index)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCustomSearchToolCall(document.RootElement, options); + return DeserializeIndex(document.RootElement, options); } - internal static RunStepCustomSearchToolCall DeserializeRunStepCustomSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) + internal static UnknownIndex DeserializeUnknownIndex(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -65,26 +57,19 @@ internal static RunStepCustomSearchToolCall DeserializeRunStepCustomSearchToolCa { return null; } - IReadOnlyDictionary bingCustomSearch = default; - string type = default; + IndexType type = "Unknown"; string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = 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(); + type = new IndexType(property.Value.GetString()); continue; } if (property.NameEquals("id"u8)) @@ -92,59 +77,95 @@ internal static RunStepCustomSearchToolCall DeserializeRunStepCustomSearchToolCa id = property.Value.GetString(); continue; } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new RunStepCustomSearchToolCall(type, id, serializedAdditionalRawData, bingCustomSearch); + return new UnknownIndex( + type, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(RunStepCustomSearchToolCall)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(Index)} does not support writing '{options.Format}' format."); } } - RunStepCustomSearchToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + Index IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + 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); + return DeserializeIndex(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RunStepCustomSearchToolCall)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(Index)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + 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) + internal static new UnknownIndex FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRunStepCustomSearchToolCall(document.RootElement); + return DeserializeUnknownIndex(document.RootElement); } /// Convert into a . internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownIndex.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownIndex.cs new file mode 100644 index 000000000000..f7f7e4eb7a0d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownIndex.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Unknown version of Index. + internal partial class UnknownIndex : Index + { + /// Initializes a new instance of . + /// Type of index. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal UnknownIndex(IndexType type, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) : base(type, id, name, version, description, tags, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownIndex() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.Serialization.cs deleted file mode 100644 index 2883b54472fc..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.Serialization.cs +++ /dev/null @@ -1,138 +0,0 @@ -// 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 -{ - internal partial class UnknownInternalConnectionProperties : 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(ConnectionProperties)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - ConnectionProperties 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(ConnectionProperties)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeConnectionProperties(document.RootElement, options); - } - - internal static UnknownInternalConnectionProperties DeserializeUnknownInternalConnectionProperties(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AuthenticationType authType = default; - ConnectionType category = default; - string target = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("authType"u8)) - { - authType = property.Value.GetString().ToAuthenticationType(); - continue; - } - if (property.NameEquals("category"u8)) - { - category = new ConnectionType(property.Value.GetString()); - continue; - } - if (property.NameEquals("target"u8)) - { - target = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownInternalConnectionProperties(authType, category, target, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ConnectionProperties)} does not support writing '{options.Format}' format."); - } - } - - ConnectionProperties 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 DeserializeConnectionProperties(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ConnectionProperties)} 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 UnknownInternalConnectionProperties FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownInternalConnectionProperties(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/UnknownInternalConnectionProperties.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.cs deleted file mode 100644 index a17524ba6e77..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of InternalConnectionProperties. - internal partial class UnknownInternalConnectionProperties : ConnectionProperties - { - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// Category of the connection. - /// The connection URL to be used for this service. - /// Keeps track of any properties unknown to the library. - internal UnknownInternalConnectionProperties(AuthenticationType authType, ConnectionType category, string target, IDictionary serializedAdditionalRawData) : base(authType, category, target, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownInternalConnectionProperties() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageContent.cs deleted file mode 100644 index 030da863c61a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageContent.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of MessageContent. - internal partial class UnknownMessageContent : MessageContent - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal UnknownMessageContent(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownMessageContent() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaContent.Serialization.cs deleted file mode 100644 index 14547bde91cc..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaContent.Serialization.cs +++ /dev/null @@ -1,132 +0,0 @@ -// 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 -{ - internal partial class UnknownMessageDeltaContent : 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(MessageDeltaContent)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - MessageDeltaContent 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(MessageDeltaContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaContent(document.RootElement, options); - } - - internal static UnknownMessageDeltaContent DeserializeUnknownMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int index = default; - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 UnknownMessageDeltaContent(index, type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaContent 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 DeserializeMessageDeltaContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaContent)} 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 UnknownMessageDeltaContent FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownMessageDeltaContent(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/UnknownMessageDeltaContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaContent.cs deleted file mode 100644 index 9aa9dd56098f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaContent.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of MessageDeltaContent. - internal partial class UnknownMessageDeltaContent : MessageDeltaContent - { - /// Initializes a new instance of . - /// The index of the content part of the message. - /// The type of content for this content part. - /// Keeps track of any properties unknown to the library. - internal UnknownMessageDeltaContent(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownMessageDeltaContent() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs deleted file mode 100644 index 7277d429898c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs +++ /dev/null @@ -1,132 +0,0 @@ -// 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 -{ - internal partial class UnknownMessageDeltaTextAnnotation : 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(MessageDeltaTextAnnotation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - MessageDeltaTextAnnotation 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(MessageDeltaTextAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); - } - - internal static UnknownMessageDeltaTextAnnotation DeserializeUnknownMessageDeltaTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int index = default; - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 UnknownMessageDeltaTextAnnotation(index, type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageDeltaTextAnnotation 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 DeserializeMessageDeltaTextAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} 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 UnknownMessageDeltaTextAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownMessageDeltaTextAnnotation(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/UnknownMessageDeltaTextAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaTextAnnotation.cs deleted file mode 100644 index c1a702e2bfb2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageDeltaTextAnnotation.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of MessageDeltaTextAnnotation. - internal partial class UnknownMessageDeltaTextAnnotation : MessageDeltaTextAnnotation - { - /// Initializes a new instance of . - /// The index of the annotation within a text content part. - /// The type of the text content annotation. - /// Keeps track of any properties unknown to the library. - internal UnknownMessageDeltaTextAnnotation(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownMessageDeltaTextAnnotation() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.Serialization.cs deleted file mode 100644 index a0dbba5d02ce..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 -{ - internal partial class UnknownMessageInputContentBlock : 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(MessageInputContentBlock)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - MessageInputContentBlock 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(MessageInputContentBlock)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageInputContentBlock(document.RootElement, options); - } - - internal static UnknownMessageInputContentBlock DeserializeUnknownMessageInputContentBlock(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageBlockType type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new MessageBlockType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownMessageInputContentBlock(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{options.Format}' format."); - } - } - - MessageInputContentBlock 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 DeserializeMessageInputContentBlock(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageInputContentBlock)} 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 UnknownMessageInputContentBlock FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownMessageInputContentBlock(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/UnknownMessageInputContentBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.cs deleted file mode 100644 index 3ad239e8a6e0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of MessageInputContentBlock. - internal partial class UnknownMessageInputContentBlock : MessageInputContentBlock - { - /// Initializes a new instance of . - /// Specifies which kind of content block this is (text, image_file, image_url, etc.). - /// Keeps track of any properties unknown to the library. - internal UnknownMessageInputContentBlock(MessageBlockType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownMessageInputContentBlock() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageTextAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageTextAnnotation.Serialization.cs deleted file mode 100644 index 925de1adb59d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageTextAnnotation.Serialization.cs +++ /dev/null @@ -1,132 +0,0 @@ -// 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 -{ - internal partial class UnknownMessageTextAnnotation : 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(MessageTextAnnotation)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - MessageTextAnnotation 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(MessageTextAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageTextAnnotation(document.RootElement, options); - } - - internal static UnknownMessageTextAnnotation DeserializeUnknownMessageTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownMessageTextAnnotation(type, text, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support writing '{options.Format}' format."); - } - } - - MessageTextAnnotation 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 DeserializeMessageTextAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageTextAnnotation)} 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 UnknownMessageTextAnnotation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownMessageTextAnnotation(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/UnknownMessageTextAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageTextAnnotation.cs deleted file mode 100644 index add6b94cd4cd..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageTextAnnotation.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of MessageTextAnnotation. - internal partial class UnknownMessageTextAnnotation : MessageTextAnnotation - { - /// Initializes a new instance of . - /// The object type. - /// The textual content associated with this text annotation item. - /// Keeps track of any properties unknown to the library. - internal UnknownMessageTextAnnotation(string type, string text, IDictionary serializedAdditionalRawData) : base(type, text, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownMessageTextAnnotation() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs deleted file mode 100644 index 27a50ed4124a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 -{ - internal partial class UnknownOpenApiAuthDetails : 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(OpenApiAuthDetails)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - OpenApiAuthDetails 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(OpenApiAuthDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenApiAuthDetails(document.RootElement, options); - } - - internal static UnknownOpenApiAuthDetails DeserializeUnknownOpenApiAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenApiAuthType type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new OpenApiAuthType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownOpenApiAuthDetails(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{options.Format}' format."); - } - } - - OpenApiAuthDetails 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 DeserializeOpenApiAuthDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenApiAuthDetails)} 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 UnknownOpenApiAuthDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownOpenApiAuthDetails(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/UnknownOpenApiAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.cs deleted file mode 100644 index 4844d77a2185..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of OpenApiAuthDetails. - internal partial class UnknownOpenApiAuthDetails : OpenApiAuthDetails - { - /// Initializes a new instance of . - /// The type of authentication, must be anonymous/connection/managed_identity. - /// Keeps track of any properties unknown to the library. - internal UnknownOpenApiAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownOpenApiAuthDetails() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredAction.cs deleted file mode 100644 index a9368a767de8..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredAction.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of RequiredAction. - internal partial class UnknownRequiredAction : RequiredAction - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal UnknownRequiredAction(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownRequiredAction() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredToolCall.cs deleted file mode 100644 index 9fa6789c3766..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRequiredToolCall.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of RequiredToolCall. - internal partial class UnknownRequiredToolCall : RequiredToolCall - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The ID of the tool call. This ID must be referenced when submitting tool outputs. - internal UnknownRequiredToolCall(string type, IDictionary serializedAdditionalRawData, string id) : base(type, serializedAdditionalRawData, id) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownRequiredToolCall() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs deleted file mode 100644 index 46ef55a2eb05..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 -{ - internal partial class UnknownRunStepCodeInterpreterToolCallOutput : 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(RunStepCodeInterpreterToolCallOutput)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - RunStepCodeInterpreterToolCallOutput 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(RunStepCodeInterpreterToolCallOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); - } - - internal static UnknownRunStepCodeInterpreterToolCallOutput DeserializeUnknownRunStepCodeInterpreterToolCallOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - 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()) - { - 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 UnknownRunStepCodeInterpreterToolCallOutput(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support writing '{options.Format}' format."); - } - } - - RunStepCodeInterpreterToolCallOutput 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 DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} 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 UnknownRunStepCodeInterpreterToolCallOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownRunStepCodeInterpreterToolCallOutput(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/UnknownRunStepCodeInterpreterToolCallOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs deleted file mode 100644 index 2fd983536cab..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of RunStepCodeInterpreterToolCallOutput. - internal partial class UnknownRunStepCodeInterpreterToolCallOutput : RunStepCodeInterpreterToolCallOutput - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal UnknownRunStepCodeInterpreterToolCallOutput(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownRunStepCodeInterpreterToolCallOutput() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs deleted file mode 100644 index 1a2f2310e7c0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs +++ /dev/null @@ -1,132 +0,0 @@ -// 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 -{ - internal partial class UnknownRunStepDeltaCodeInterpreterOutput : 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(RunStepDeltaCodeInterpreterOutput)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - RunStepDeltaCodeInterpreterOutput 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(RunStepDeltaCodeInterpreterOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); - } - - internal static UnknownRunStepDeltaCodeInterpreterOutput DeserializeUnknownRunStepDeltaCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int index = default; - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - 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 UnknownRunStepDeltaCodeInterpreterOutput(index, type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaCodeInterpreterOutput 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 DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} 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 UnknownRunStepDeltaCodeInterpreterOutput FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownRunStepDeltaCodeInterpreterOutput(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/UnknownRunStepDeltaCodeInterpreterOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs deleted file mode 100644 index 2aaf69a1c20b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of RunStepDeltaCodeInterpreterOutput. - internal partial class UnknownRunStepDeltaCodeInterpreterOutput : RunStepDeltaCodeInterpreterOutput - { - /// Initializes a new instance of . - /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. - /// The type of the streaming run step tool call's Code Interpreter output. - /// Keeps track of any properties unknown to the library. - internal UnknownRunStepDeltaCodeInterpreterOutput(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownRunStepDeltaCodeInterpreterOutput() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaDetail.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaDetail.cs deleted file mode 100644 index a5ac9c43bae4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaDetail.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of RunStepDeltaDetail. - internal partial class UnknownRunStepDeltaDetail : RunStepDeltaDetail - { - /// Initializes a new instance of . - /// The object type for the run step detail object. - /// Keeps track of any properties unknown to the library. - internal UnknownRunStepDeltaDetail(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownRunStepDeltaDetail() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs deleted file mode 100644 index 0879c7902af4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs +++ /dev/null @@ -1,138 +0,0 @@ -// 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 -{ - internal partial class UnknownRunStepDeltaToolCall : 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(RunStepDeltaToolCall)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - RunStepDeltaToolCall 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(RunStepDeltaToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDeltaToolCall(document.RootElement, options); - } - - internal static UnknownRunStepDeltaToolCall DeserializeUnknownRunStepDeltaToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int index = default; - string id = default; - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - 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 UnknownRunStepDeltaToolCall(index, id, type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{options.Format}' format."); - } - } - - RunStepDeltaToolCall 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 DeserializeRunStepDeltaToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} 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 UnknownRunStepDeltaToolCall FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownRunStepDeltaToolCall(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/UnknownRunStepDeltaToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaToolCall.cs deleted file mode 100644 index 2c31d5c2b174..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDeltaToolCall.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of RunStepDeltaToolCall. - internal partial class UnknownRunStepDeltaToolCall : RunStepDeltaToolCall - { - /// Initializes a new instance of . - /// The index of the tool call detail in the run step's tool_calls array. - /// The ID of the tool call, used when submitting outputs to the run. - /// The type of the tool call detail item in a streaming run step's details. - /// Keeps track of any properties unknown to the library. - internal UnknownRunStepDeltaToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData) : base(index, id, type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownRunStepDeltaToolCall() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDetails.Serialization.cs deleted file mode 100644 index acfca39a2efb..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDetails.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 -{ - internal partial class UnknownRunStepDetails : 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(RunStepDetails)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - RunStepDetails 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(RunStepDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDetails(document.RootElement, options); - } - - internal static UnknownRunStepDetails DeserializeUnknownRunStepDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunStepType type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new RunStepType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepDetails(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{options.Format}' format."); - } - } - - RunStepDetails 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 DeserializeRunStepDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDetails)} 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 UnknownRunStepDetails FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownRunStepDetails(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/UnknownRunStepDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDetails.cs deleted file mode 100644 index a8b39aafcbf3..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepDetails.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of RunStepDetails. - internal partial class UnknownRunStepDetails : RunStepDetails - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal UnknownRunStepDetails(RunStepType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownRunStepDetails() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepToolCall.cs deleted file mode 100644 index 26e2ee7649c9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRunStepToolCall.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of RunStepToolCall. - internal partial class UnknownRunStepToolCall : RunStepToolCall - { - /// 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. - internal UnknownRunStepToolCall(string type, string id, IDictionary serializedAdditionalRawData) : base(type, id, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownRunStepToolCall() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetModelConfig.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.Serialization.cs similarity index 63% rename from sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetModelConfig.Serialization.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.Serialization.cs index 532b40d15829..c24f6413031c 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetModelConfig.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.AI.Projects { - internal partial class UnknownTargetModelConfig : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownTargetConfig : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,28 +28,28 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(TargetModelConfig)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(TargetConfig)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); } - TargetModelConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + TargetConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(TargetModelConfig)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(TargetConfig)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTargetModelConfig(document.RootElement, options); + return DeserializeTargetConfig(document.RootElement, options); } - internal static UnknownTargetModelConfig DeserializeUnknownTargetModelConfig(JsonElement element, ModelReaderWriterOptions options = null) + internal static UnknownTargetConfig DeserializeUnknownTargetConfig(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -73,53 +73,53 @@ internal static UnknownTargetModelConfig DeserializeUnknownTargetModelConfig(Jso } } serializedAdditionalRawData = rawDataDictionary; - return new UnknownTargetModelConfig(type, serializedAdditionalRawData); + return new UnknownTargetConfig(type, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); default: - throw new FormatException($"The model {nameof(TargetModelConfig)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(TargetConfig)} does not support writing '{options.Format}' format."); } } - TargetModelConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + TargetConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTargetModelConfig(document.RootElement, options); + return DeserializeTargetConfig(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(TargetModelConfig)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(TargetConfig)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new UnknownTargetModelConfig FromResponse(Response response) + internal static new UnknownTargetConfig FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownTargetModelConfig(document.RootElement); + return DeserializeUnknownTargetConfig(document.RootElement); } /// Convert into a . internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetModelConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.cs similarity index 57% rename from sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetModelConfig.cs rename to sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.cs index b7130f7a857a..c9e64735546c 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetModelConfig.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.cs @@ -10,18 +10,18 @@ namespace Azure.AI.Projects { - /// Unknown version of TargetModelConfig. - internal partial class UnknownTargetModelConfig : TargetModelConfig + /// Unknown version of TargetConfig. + internal partial class UnknownTargetConfig : TargetConfig { - /// Initializes a new instance of . + /// Initializes a new instance of . /// Type of the model configuration. /// Keeps track of any properties unknown to the library. - internal UnknownTargetModelConfig(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + internal UnknownTargetConfig(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { } - /// Initializes a new instance of for deserialization. - internal UnknownTargetModelConfig() + /// Initializes a new instance of for deserialization. + internal UnknownTargetConfig() { } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownToolDefinition.Serialization.cs deleted file mode 100644 index e67762afd06d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownToolDefinition.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 -{ - internal partial class UnknownToolDefinition : 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(ToolDefinition)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - ToolDefinition 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(ToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolDefinition(document.RootElement, options); - } - - internal static UnknownToolDefinition DeserializeUnknownToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - 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()) - { - 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 UnknownToolDefinition(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - ToolDefinition 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 DeserializeToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolDefinition)} 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 UnknownToolDefinition FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownToolDefinition(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/UnknownToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownToolDefinition.cs deleted file mode 100644 index 99bbba5bf00a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownToolDefinition.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of ToolDefinition. - internal partial class UnknownToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal UnknownToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownToolDefinition() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.Serialization.cs deleted file mode 100644 index 64ddec40e0ff..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 -{ - internal partial class UnknownTrigger : 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(Trigger)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - Trigger 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(Trigger)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTrigger(document.RootElement, options); - } - - internal static UnknownTrigger DeserializeUnknownTrigger(JsonElement element, ModelReaderWriterOptions options = null) - { - 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()) - { - 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 UnknownTrigger(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(Trigger)} does not support writing '{options.Format}' format."); - } - } - - Trigger 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 DeserializeTrigger(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Trigger)} 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 UnknownTrigger FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownTrigger(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/UnknownTrigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.cs deleted file mode 100644 index 61ca52ea3445..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of Trigger. - internal partial class UnknownTrigger : Trigger - { - /// Initializes a new instance of . - /// Type of the trigger. - /// Keeps track of any properties unknown to the library. - internal UnknownTrigger(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownTrigger() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs deleted file mode 100644 index 2b2145e38096..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 -{ - internal partial class UnknownVectorStoreChunkingStrategyRequest : 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(VectorStoreChunkingStrategyRequest)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - VectorStoreChunkingStrategyRequest 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(VectorStoreChunkingStrategyRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); - } - - internal static UnknownVectorStoreChunkingStrategyRequest DeserializeUnknownVectorStoreChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - VectorStoreChunkingStrategyRequestType type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownVectorStoreChunkingStrategyRequest(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreChunkingStrategyRequest 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 DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} 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 UnknownVectorStoreChunkingStrategyRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownVectorStoreChunkingStrategyRequest(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/UnknownVectorStoreChunkingStrategyRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs deleted file mode 100644 index 7ca4d51daf75..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of VectorStoreChunkingStrategyRequest. - internal partial class UnknownVectorStoreChunkingStrategyRequest : VectorStoreChunkingStrategyRequest - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal UnknownVectorStoreChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownVectorStoreChunkingStrategyRequest() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs deleted file mode 100644 index cc8784a02603..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 -{ - internal partial class UnknownVectorStoreChunkingStrategyResponse : 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(VectorStoreChunkingStrategyResponse)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - VectorStoreChunkingStrategyResponse 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(VectorStoreChunkingStrategyResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); - } - - internal static UnknownVectorStoreChunkingStrategyResponse DeserializeUnknownVectorStoreChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - VectorStoreChunkingStrategyResponseType type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownVectorStoreChunkingStrategyResponse(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreChunkingStrategyResponse 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 DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} 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 UnknownVectorStoreChunkingStrategyResponse FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownVectorStoreChunkingStrategyResponse(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/UnknownVectorStoreChunkingStrategyResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs deleted file mode 100644 index d9896a124b6f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Unknown version of VectorStoreChunkingStrategyResponse. - internal partial class UnknownVectorStoreChunkingStrategyResponse : VectorStoreChunkingStrategyResponse - { - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal UnknownVectorStoreChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownVectorStoreChunkingStrategyResponse() - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.Serialization.cs deleted file mode 100644 index 5358d95fca9e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.Serialization.cs +++ /dev/null @@ -1,374 +0,0 @@ -// 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 -{ - internal partial class UpdateAgentRequest : 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(UpdateAgentRequest)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(Model)) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); - } - if (Optional.IsDefined(Name)) - { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } - } - if (Optional.IsDefined(Description)) - { - if (Description != null) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - else - { - writer.WriteNull("description"); - } - } - if (Optional.IsDefined(Instructions)) - { - if (Instructions != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); - } - else - { - writer.WriteNull("instructions"); - } - } - if (Optional.IsCollectionDefined(Tools)) - { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(ToolResources)) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - if (Optional.IsDefined(Temperature)) - { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } - } - if (Optional.IsDefined(TopP)) - { - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } - } - if (Optional.IsDefined(ResponseFormat)) - { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(ResponseFormat); -#else - using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else - { - writer.WriteNull("response_format"); - } - } - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - UpdateAgentRequest 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(UpdateAgentRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUpdateAgentRequest(document.RootElement, options); - } - - internal static UpdateAgentRequest DeserializeUpdateAgentRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string model = default; - string name = default; - string description = default; - string instructions = default; - IReadOnlyList tools = default; - ToolResources toolResources = default; - float? temperature = default; - float? topP = default; - BinaryData responseFormat = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("description"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - description = null; - continue; - } - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("instructions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); - continue; - } - if (property.NameEquals("tools"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; - } - if (property.NameEquals("tool_resources"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - toolResources = ToolResources.DeserializeToolResources(property.Value, options); - continue; - } - if (property.NameEquals("temperature"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("top_p"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("response_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UpdateAgentRequest( - model, - name, - description, - instructions, - tools ?? new ChangeTrackingList(), - toolResources, - temperature, - topP, - responseFormat, - metadata ?? new ChangeTrackingDictionary(), - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(UpdateAgentRequest)} does not support writing '{options.Format}' format."); - } - } - - UpdateAgentRequest 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 DeserializeUpdateAgentRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(UpdateAgentRequest)} 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 UpdateAgentRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateAgentRequest(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/UpdateAgentRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.cs deleted file mode 100644 index b24cf0bd2268..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.cs +++ /dev/null @@ -1,179 +0,0 @@ -// 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 UpdateAgentRequest. - internal partial class UpdateAgentRequest - { - /// - /// 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 . - internal UpdateAgentRequest() - { - Tools = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The ID of the model to use. - /// The modified name for the agent to use. - /// The modified description for the agent to use. - /// The modified system instructions for the new agent to use. - /// - /// 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 . - /// - /// - /// 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` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - /// The response format of the tool calls used by this agent. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal UpdateAgentRequest(string model, string name, string description, string instructions, IReadOnlyList tools, ToolResources toolResources, float? temperature, float? topP, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Model = model; - Name = name; - Description = description; - Instructions = instructions; - Tools = tools; - ToolResources = toolResources; - Temperature = temperature; - TopP = topP; - ResponseFormat = responseFormat; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The ID of the model to use. - public string Model { get; } - /// The modified name for the agent to use. - public string Name { get; } - /// The modified description for the agent to use. - public string Description { get; } - /// The modified system instructions for the new agent to use. - public string Instructions { get; } - /// - /// 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 . - /// - public IReadOnlyList Tools { get; } - /// - /// 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` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - /// - public ToolResources ToolResources { get; } - /// - /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, - /// while lower values like 0.2 will make it more focused and deterministic. - /// - public float? Temperature { get; } - /// - /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. - /// - /// We generally recommend altering this or temperature but not both. - /// - public float? TopP { get; } - /// - /// The response format of the tool calls used by this agent. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// - /// Supported types: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData ResponseFormat { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs deleted file mode 100644 index 7efed47b989e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs +++ /dev/null @@ -1,159 +0,0 @@ -// 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 UpdateCodeInterpreterToolResourceOptions : 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(UpdateCodeInterpreterToolResourceOptions)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(FileIds)) - { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - 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 - } - } - } - - UpdateCodeInterpreterToolResourceOptions 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(UpdateCodeInterpreterToolResourceOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUpdateCodeInterpreterToolResourceOptions(document.RootElement, options); - } - - internal static UpdateCodeInterpreterToolResourceOptions DeserializeUpdateCodeInterpreterToolResourceOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file_ids"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UpdateCodeInterpreterToolResourceOptions(fileIds ?? 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support writing '{options.Format}' format."); - } - } - - UpdateCodeInterpreterToolResourceOptions 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 DeserializeUpdateCodeInterpreterToolResourceOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} 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 UpdateCodeInterpreterToolResourceOptions FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateCodeInterpreterToolResourceOptions(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/UpdateCodeInterpreterToolResourceOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs deleted file mode 100644 index 402e29bdc278..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Request object to update `code_interpreted` tool resources. - public partial class UpdateCodeInterpreterToolResourceOptions - { - /// - /// 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 . - public UpdateCodeInterpreterToolResourceOptions() - { - FileIds = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// A list of file IDs to override the current list of the agent. - /// Keeps track of any properties unknown to the library. - internal UpdateCodeInterpreterToolResourceOptions(IList fileIds, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// A list of file IDs to override the current list of the agent. - public IList FileIds { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs deleted file mode 100644 index 686d9d8c8e6e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs +++ /dev/null @@ -1,159 +0,0 @@ -// 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 UpdateFileSearchToolResourceOptions : 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(UpdateFileSearchToolResourceOptions)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(VectorStoreIds)) - { - writer.WritePropertyName("vector_store_ids"u8); - writer.WriteStartArray(); - foreach (var item in VectorStoreIds) - { - writer.WriteStringValue(item); - } - 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 - } - } - } - - UpdateFileSearchToolResourceOptions 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(UpdateFileSearchToolResourceOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUpdateFileSearchToolResourceOptions(document.RootElement, options); - } - - internal static UpdateFileSearchToolResourceOptions DeserializeUpdateFileSearchToolResourceOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList vectorStoreIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("vector_store_ids"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - vectorStoreIds = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UpdateFileSearchToolResourceOptions(vectorStoreIds ?? 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support writing '{options.Format}' format."); - } - } - - UpdateFileSearchToolResourceOptions 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 DeserializeUpdateFileSearchToolResourceOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} 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 UpdateFileSearchToolResourceOptions FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateFileSearchToolResourceOptions(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/UpdateFileSearchToolResourceOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateFileSearchToolResourceOptions.cs deleted file mode 100644 index 892e93500be8..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateFileSearchToolResourceOptions.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Request object to update `file_search` tool resources. - public partial class UpdateFileSearchToolResourceOptions - { - /// - /// 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 . - public UpdateFileSearchToolResourceOptions() - { - VectorStoreIds = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// A list of vector store IDs to override the current list of the agent. - /// Keeps track of any properties unknown to the library. - internal UpdateFileSearchToolResourceOptions(IList vectorStoreIds, IDictionary serializedAdditionalRawData) - { - VectorStoreIds = vectorStoreIds; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// A list of vector store IDs to override the current list of the agent. - public IList VectorStoreIds { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMessageRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMessageRequest.cs deleted file mode 100644 index 45b3cf31de2b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMessageRequest.cs +++ /dev/null @@ -1,66 +0,0 @@ -// 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 UpdateMessageRequest. - internal partial class UpdateMessageRequest - { - /// - /// 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 . - internal UpdateMessageRequest() - { - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal UpdateMessageRequest(IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateRunRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateRunRequest.Serialization.cs deleted file mode 100644 index a489703d6c73..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateRunRequest.Serialization.cs +++ /dev/null @@ -1,167 +0,0 @@ -// 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 -{ - internal partial class UpdateRunRequest : 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(UpdateRunRequest)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(Metadata)) - { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - } - 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 - } - } - } - - UpdateRunRequest 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(UpdateRunRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUpdateRunRequest(document.RootElement, options); - } - - internal static UpdateRunRequest DeserializeUpdateRunRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(UpdateRunRequest)} does not support writing '{options.Format}' format."); - } - } - - UpdateRunRequest 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 DeserializeUpdateRunRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(UpdateRunRequest)} 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 UpdateRunRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateRunRequest(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/UpdateRunRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateRunRequest.cs deleted file mode 100644 index 356bad9de457..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateRunRequest.cs +++ /dev/null @@ -1,66 +0,0 @@ -// 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 UpdateRunRequest. - internal partial class UpdateRunRequest - { - /// - /// 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 . - internal UpdateRunRequest() - { - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal UpdateRunRequest(IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateThreadRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateThreadRequest.cs deleted file mode 100644 index 674b76d10fba..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateThreadRequest.cs +++ /dev/null @@ -1,78 +0,0 @@ -// 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 UpdateThreadRequest. - internal partial class UpdateThreadRequest - { - /// - /// 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 . - internal UpdateThreadRequest() - { - Metadata = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs - /// - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal UpdateThreadRequest(ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - ToolResources = toolResources; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - /// a list of vector store IDs - /// - public ToolResources ToolResources { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateToolResourcesOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateToolResourcesOptions.Serialization.cs deleted file mode 100644 index aeaab45ce3b5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateToolResourcesOptions.Serialization.cs +++ /dev/null @@ -1,179 +0,0 @@ -// 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 UpdateToolResourcesOptions : 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(UpdateToolResourcesOptions)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (Optional.IsDefined(AzureAISearch)) - { - writer.WritePropertyName("azure_ai_search"u8); - writer.WriteObjectValue(AzureAISearch, options); - } - 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 - } - } - } - - UpdateToolResourcesOptions 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(UpdateToolResourcesOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUpdateToolResourcesOptions(document.RootElement, options); - } - - internal static UpdateToolResourcesOptions DeserializeUpdateToolResourcesOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - UpdateCodeInterpreterToolResourceOptions codeInterpreter = default; - UpdateFileSearchToolResourceOptions fileSearch = default; - AzureAISearchResource azureAiSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code_interpreter"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = UpdateCodeInterpreterToolResourceOptions.DeserializeUpdateCodeInterpreterToolResourceOptions(property.Value, options); - continue; - } - if (property.NameEquals("file_search"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = UpdateFileSearchToolResourceOptions.DeserializeUpdateFileSearchToolResourceOptions(property.Value, options); - continue; - } - if (property.NameEquals("azure_ai_search"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - azureAiSearch = AzureAISearchResource.DeserializeAzureAISearchResource(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UpdateToolResourcesOptions(codeInterpreter, fileSearch, azureAiSearch, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support writing '{options.Format}' format."); - } - } - - UpdateToolResourcesOptions 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 DeserializeUpdateToolResourcesOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} 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 UpdateToolResourcesOptions FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUpdateToolResourcesOptions(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/UpdateToolResourcesOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateToolResourcesOptions.cs deleted file mode 100644 index 1ebcca9d85f1..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateToolResourcesOptions.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// Request object. 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` tool requires a list of file IDs, while the `file_search` tool requires a list of - /// vector store IDs. - /// - public partial class UpdateToolResourcesOptions - { - /// - /// 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 . - public UpdateToolResourcesOptions() - { - } - - /// Initializes a new instance of . - /// - /// Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - /// associated with the tool. - /// - /// Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. - /// Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. - /// Keeps track of any properties unknown to the library. - internal UpdateToolResourcesOptions(UpdateCodeInterpreterToolResourceOptions codeInterpreter, UpdateFileSearchToolResourceOptions fileSearch, AzureAISearchResource azureAISearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - AzureAISearch = azureAISearch; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - /// associated with the tool. - /// - public UpdateCodeInterpreterToolResourceOptions CodeInterpreter { get; set; } - /// Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. - public UpdateFileSearchToolResourceOptions FileSearch { get; set; } - /// Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. - public AzureAISearchResource AzureAISearch { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UploadFileRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UploadFileRequest.Serialization.cs deleted file mode 100644 index 3dd10c637a6a..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UploadFileRequest.Serialization.cs +++ /dev/null @@ -1,179 +0,0 @@ -// 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.IO; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - internal partial class UploadFileRequest : 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(UploadFileRequest)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("file"u8); - writer.WriteObjectValue(Data, options); - writer.WritePropertyName("purpose"u8); - writer.WriteStringValue(Purpose.ToString()); - if (Optional.IsDefined(Filename)) - { - writer.WritePropertyName("filename"u8); - writer.WriteStringValue(Filename); - } - 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 - } - } - } - - UploadFileRequest 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(UploadFileRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUploadFileRequest(document.RootElement, options); - } - - internal static UploadFileRequest DeserializeUploadFileRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - File file = default; - AgentFilePurpose purpose = default; - string filename = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file"u8)) - { - file = File.DeserializeFile(property.Value, options); - continue; - } - if (property.NameEquals("purpose"u8)) - { - purpose = new AgentFilePurpose(property.Value.GetString()); - continue; - } - if (property.NameEquals("filename"u8)) - { - filename = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UploadFileRequest(file, purpose, filename, serializedAdditionalRawData); - } - - private BinaryData SerializeMultipart(ModelReaderWriterOptions options) - { - using MultipartFormDataRequestContent content = ToMultipartRequestContent(); - using MemoryStream stream = new MemoryStream(); - content.WriteTo(stream); - if (stream.Position > int.MaxValue) - { - return BinaryData.FromStream(stream); - } - else - { - return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); - } - } - - 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, AzureAIProjectsContext.Default); - case "MFD": - return SerializeMultipart(options); - default: - throw new FormatException($"The model {nameof(UploadFileRequest)} does not support writing '{options.Format}' format."); - } - } - - UploadFileRequest 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 DeserializeUploadFileRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(UploadFileRequest)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static UploadFileRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUploadFileRequest(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/UploadFileRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UploadFileRequest.cs deleted file mode 100644 index aea9f77b507d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UploadFileRequest.cs +++ /dev/null @@ -1,85 +0,0 @@ -// 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 UploadFileRequest. - internal partial class UploadFileRequest - { - /// - /// 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 file data, in bytes. - /// The intended purpose of the uploaded file. Use `assistants` for Agents and Message files, `vision` for Agents image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. - /// is null. - public UploadFileRequest(File data, AgentFilePurpose purpose) - { - Argument.AssertNotNull(data, nameof(data)); - - Data = data; - Purpose = purpose; - } - - /// Initializes a new instance of . - /// The file data, in bytes. - /// The intended purpose of the uploaded file. Use `assistants` for Agents and Message files, `vision` for Agents image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. - /// The name of the file. - /// Keeps track of any properties unknown to the library. - internal UploadFileRequest(File data, AgentFilePurpose purpose, string filename, IDictionary serializedAdditionalRawData) - { - Data = data; - Purpose = purpose; - Filename = filename; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal UploadFileRequest() - { - } - - /// The file data, in bytes. - public File Data { get; } - /// The intended purpose of the uploaded file. Use `assistants` for Agents and Message files, `vision` for Agents image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. - public AgentFilePurpose Purpose { get; } - /// The name of the file. - public string Filename { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStore.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStore.Serialization.cs deleted file mode 100644 index 7b40e3394d1e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStore.Serialization.cs +++ /dev/null @@ -1,291 +0,0 @@ -// 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 VectorStore : 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(VectorStore)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("usage_bytes"u8); - writer.WriteNumberValue(UsageBytes); - writer.WritePropertyName("file_counts"u8); - writer.WriteObjectValue(FileCounts, options); - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); - if (Optional.IsDefined(ExpiresAfter)) - { - writer.WritePropertyName("expires_after"u8); - writer.WriteObjectValue(ExpiresAfter, options); - } - if (Optional.IsDefined(ExpiresAt)) - { - if (ExpiresAt != null) - { - writer.WritePropertyName("expires_at"u8); - writer.WriteNumberValue(ExpiresAt.Value, "U"); - } - else - { - writer.WriteNull("expires_at"); - } - } - if (LastActiveAt != null) - { - writer.WritePropertyName("last_active_at"u8); - writer.WriteNumberValue(LastActiveAt.Value, "U"); - } - else - { - writer.WriteNull("last_active_at"); - } - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } - 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 - } - } - } - - VectorStore 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(VectorStore)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStore(document.RootElement, options); - } - - internal static VectorStore DeserializeVectorStore(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - VectorStoreObject @object = default; - DateTimeOffset createdAt = default; - string name = default; - int usageBytes = default; - VectorStoreFileCount fileCounts = default; - VectorStoreStatus status = default; - VectorStoreExpirationPolicy expiresAfter = default; - DateTimeOffset? expiresAt = default; - DateTimeOffset? lastActiveAt = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new VectorStoreObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("usage_bytes"u8)) - { - usageBytes = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("file_counts"u8)) - { - fileCounts = VectorStoreFileCount.DeserializeVectorStoreFileCount(property.Value, options); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new VectorStoreStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("expires_after"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); - continue; - } - if (property.NameEquals("expires_at"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - expiresAt = null; - continue; - } - expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("last_active_at"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastActiveAt = null; - continue; - } - lastActiveAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStore( - id, - @object, - createdAt, - name, - usageBytes, - fileCounts, - status, - expiresAfter, - expiresAt, - lastActiveAt, - metadata, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{options.Format}' format."); - } - } - - VectorStore 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 DeserializeVectorStore(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStore)} 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 VectorStore FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStore(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/VectorStore.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStore.cs deleted file mode 100644 index c60dd6fffb48..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStore.cs +++ /dev/null @@ -1,132 +0,0 @@ -// 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 vector store is a collection of processed files can be used by the `file_search` tool. - public partial class VectorStore - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// The Unix timestamp (in seconds) for when the vector store was created. - /// The name of the vector store. - /// The total number of bytes used by the files in the vector store. - /// Files count grouped by status processed or being processed by this vector store. - /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. - /// The Unix timestamp (in seconds) for when the vector store was last active. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// , or is null. - internal VectorStore(string id, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCount fileCounts, VectorStoreStatus status, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(fileCounts, nameof(fileCounts)); - - Id = id; - CreatedAt = createdAt; - Name = name; - UsageBytes = usageBytes; - FileCounts = fileCounts; - Status = status; - LastActiveAt = lastActiveAt; - Metadata = metadata; - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always `vector_store`. - /// The Unix timestamp (in seconds) for when the vector store was created. - /// The name of the vector store. - /// The total number of bytes used by the files in the vector store. - /// Files count grouped by status processed or being processed by this vector store. - /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. - /// Details on when this vector store expires. - /// The Unix timestamp (in seconds) for when the vector store will expire. - /// The Unix timestamp (in seconds) for when the vector store was last active. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// Keeps track of any properties unknown to the library. - internal VectorStore(string id, VectorStoreObject @object, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCount fileCounts, VectorStoreStatus status, VectorStoreExpirationPolicy expiresAfter, DateTimeOffset? expiresAt, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - Name = name; - UsageBytes = usageBytes; - FileCounts = fileCounts; - Status = status; - ExpiresAfter = expiresAfter; - ExpiresAt = expiresAt; - LastActiveAt = lastActiveAt; - Metadata = metadata; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStore() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - /// The object type, which is always `vector_store`. - public VectorStoreObject Object { get; } = VectorStoreObject.VectorStore; - - /// The Unix timestamp (in seconds) for when the vector store was created. - public DateTimeOffset CreatedAt { get; } - /// The name of the vector store. - public string Name { get; } - /// The total number of bytes used by the files in the vector store. - public int UsageBytes { get; } - /// Files count grouped by status processed or being processed by this vector store. - public VectorStoreFileCount FileCounts { get; } - /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. - public VectorStoreStatus Status { get; } - /// Details on when this vector store expires. - public VectorStoreExpirationPolicy ExpiresAfter { get; } - /// The Unix timestamp (in seconds) for when the vector store will expire. - public DateTimeOffset? ExpiresAt { get; } - /// The Unix timestamp (in seconds) for when the vector store was last active. - public DateTimeOffset? LastActiveAt { get; } - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs deleted file mode 100644 index 5827a2ccda26..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 VectorStoreAutoChunkingStrategyRequest : 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(VectorStoreAutoChunkingStrategyRequest)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - VectorStoreAutoChunkingStrategyRequest 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(VectorStoreAutoChunkingStrategyRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreAutoChunkingStrategyRequest(document.RootElement, options); - } - - internal static VectorStoreAutoChunkingStrategyRequest DeserializeVectorStoreAutoChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - VectorStoreChunkingStrategyRequestType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreAutoChunkingStrategyRequest(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreAutoChunkingStrategyRequest 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 DeserializeVectorStoreAutoChunkingStrategyRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} 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 VectorStoreAutoChunkingStrategyRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreAutoChunkingStrategyRequest(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/VectorStoreAutoChunkingStrategyRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs deleted file mode 100644 index eb0eaa3efb3c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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 default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400. - public partial class VectorStoreAutoChunkingStrategyRequest : VectorStoreChunkingStrategyRequest - { - /// Initializes a new instance of . - public VectorStoreAutoChunkingStrategyRequest() - { - Type = VectorStoreChunkingStrategyRequestType.Auto; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal VectorStoreAutoChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs deleted file mode 100644 index 28c8fc243b8c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 VectorStoreAutoChunkingStrategyResponse : 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(VectorStoreAutoChunkingStrategyResponse)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - VectorStoreAutoChunkingStrategyResponse 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(VectorStoreAutoChunkingStrategyResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreAutoChunkingStrategyResponse(document.RootElement, options); - } - - internal static VectorStoreAutoChunkingStrategyResponse DeserializeVectorStoreAutoChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - VectorStoreChunkingStrategyResponseType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreAutoChunkingStrategyResponse(type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreAutoChunkingStrategyResponse 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 DeserializeVectorStoreAutoChunkingStrategyResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} 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 VectorStoreAutoChunkingStrategyResponse FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreAutoChunkingStrategyResponse(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/VectorStoreAutoChunkingStrategyResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs deleted file mode 100644 index d4911fb0201f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the chunking_strategy concept was introduced in the API. - public partial class VectorStoreAutoChunkingStrategyResponse : VectorStoreChunkingStrategyResponse - { - /// Initializes a new instance of . - internal VectorStoreAutoChunkingStrategyResponse() - { - Type = VectorStoreChunkingStrategyResponseType.Other; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal VectorStoreAutoChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs deleted file mode 100644 index 53108bd09669..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownVectorStoreChunkingStrategyRequest))] - public partial class VectorStoreChunkingStrategyRequest : 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(VectorStoreChunkingStrategyRequest)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - 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 - } - } - } - - VectorStoreChunkingStrategyRequest 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(VectorStoreChunkingStrategyRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); - } - - internal static VectorStoreChunkingStrategyRequest DeserializeVectorStoreChunkingStrategyRequest(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 "auto": return VectorStoreAutoChunkingStrategyRequest.DeserializeVectorStoreAutoChunkingStrategyRequest(element, options); - case "static": return VectorStoreStaticChunkingStrategyRequest.DeserializeVectorStoreStaticChunkingStrategyRequest(element, options); - } - } - return UnknownVectorStoreChunkingStrategyRequest.DeserializeUnknownVectorStoreChunkingStrategyRequest(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreChunkingStrategyRequest 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 DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} 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 VectorStoreChunkingStrategyRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreChunkingStrategyRequest(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/VectorStoreChunkingStrategyRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyRequest.cs deleted file mode 100644 index 3b63e8825cd6..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyRequest.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// An abstract representation of a vector store chunking strategy configuration. - /// 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 VectorStoreChunkingStrategyRequest - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected VectorStoreChunkingStrategyRequest() - { - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal VectorStoreChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The object type. - internal VectorStoreChunkingStrategyRequestType Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyRequestType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyRequestType.cs deleted file mode 100644 index 225312c10cf2..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyRequestType.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Type of chunking strategy. - internal readonly partial struct VectorStoreChunkingStrategyRequestType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreChunkingStrategyRequestType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string StaticValue = "static"; - - /// auto. - public static VectorStoreChunkingStrategyRequestType Auto { get; } = new VectorStoreChunkingStrategyRequestType(AutoValue); - /// static. - public static VectorStoreChunkingStrategyRequestType Static { get; } = new VectorStoreChunkingStrategyRequestType(StaticValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreChunkingStrategyRequestType left, VectorStoreChunkingStrategyRequestType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreChunkingStrategyRequestType left, VectorStoreChunkingStrategyRequestType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreChunkingStrategyRequestType(string value) => new VectorStoreChunkingStrategyRequestType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreChunkingStrategyRequestType other && Equals(other); - /// - public bool Equals(VectorStoreChunkingStrategyRequestType 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs deleted file mode 100644 index 586dacfd8568..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Projects -{ - [PersistableModelProxy(typeof(UnknownVectorStoreChunkingStrategyResponse))] - public partial class VectorStoreChunkingStrategyResponse : 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(VectorStoreChunkingStrategyResponse)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - 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 - } - } - } - - VectorStoreChunkingStrategyResponse 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(VectorStoreChunkingStrategyResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); - } - - internal static VectorStoreChunkingStrategyResponse DeserializeVectorStoreChunkingStrategyResponse(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 "other": return VectorStoreAutoChunkingStrategyResponse.DeserializeVectorStoreAutoChunkingStrategyResponse(element, options); - case "static": return VectorStoreStaticChunkingStrategyResponse.DeserializeVectorStoreStaticChunkingStrategyResponse(element, options); - } - } - return UnknownVectorStoreChunkingStrategyResponse.DeserializeUnknownVectorStoreChunkingStrategyResponse(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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreChunkingStrategyResponse 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 DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} 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 VectorStoreChunkingStrategyResponse FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreChunkingStrategyResponse(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/VectorStoreChunkingStrategyResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyResponse.cs deleted file mode 100644 index 66997d497a2b..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyResponse.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// - /// An abstract representation of a vector store chunking strategy configuration. - /// 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 VectorStoreChunkingStrategyResponse - { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - protected VectorStoreChunkingStrategyResponse() - { - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal VectorStoreChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) - { - Type = type; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The object type. - internal VectorStoreChunkingStrategyResponseType Type { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyResponseType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyResponseType.cs deleted file mode 100644 index af95ef419660..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreChunkingStrategyResponseType.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Type of chunking strategy. - internal readonly partial struct VectorStoreChunkingStrategyResponseType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreChunkingStrategyResponseType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string OtherValue = "other"; - private const string StaticValue = "static"; - - /// other. - public static VectorStoreChunkingStrategyResponseType Other { get; } = new VectorStoreChunkingStrategyResponseType(OtherValue); - /// static. - public static VectorStoreChunkingStrategyResponseType Static { get; } = new VectorStoreChunkingStrategyResponseType(StaticValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreChunkingStrategyResponseType left, VectorStoreChunkingStrategyResponseType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreChunkingStrategyResponseType left, VectorStoreChunkingStrategyResponseType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreChunkingStrategyResponseType(string value) => new VectorStoreChunkingStrategyResponseType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreChunkingStrategyResponseType other && Equals(other); - /// - public bool Equals(VectorStoreChunkingStrategyResponseType 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfiguration.Serialization.cs deleted file mode 100644 index c3efaf8d003f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfiguration.Serialization.cs +++ /dev/null @@ -1,152 +0,0 @@ -// 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 VectorStoreConfiguration : 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(VectorStoreConfiguration)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("data_sources"u8); - writer.WriteStartArray(); - foreach (var item in DataSources) - { - 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 - } - } - } - - VectorStoreConfiguration 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(VectorStoreConfiguration)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreConfiguration(document.RootElement, options); - } - - internal static VectorStoreConfiguration DeserializeVectorStoreConfiguration(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList dataSources = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("data_sources"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(VectorStoreDataSource.DeserializeVectorStoreDataSource(item, options)); - } - dataSources = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreConfiguration(dataSources, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreConfiguration)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreConfiguration 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 DeserializeVectorStoreConfiguration(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreConfiguration)} 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 VectorStoreConfiguration FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreConfiguration(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/VectorStoreConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfiguration.cs deleted file mode 100644 index 21d41af59f98..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfiguration.cs +++ /dev/null @@ -1,79 +0,0 @@ -// 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 -{ - /// - /// Vector storage configuration is the list of data sources, used when multiple - /// files can be used for the enterprise file search. - /// - public partial class VectorStoreConfiguration - { - /// - /// 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 . - /// Data sources. - /// is null. - public VectorStoreConfiguration(IEnumerable dataSources) - { - Argument.AssertNotNull(dataSources, nameof(dataSources)); - - DataSources = dataSources.ToList(); - } - - /// Initializes a new instance of . - /// Data sources. - /// Keeps track of any properties unknown to the library. - internal VectorStoreConfiguration(IList dataSources, IDictionary serializedAdditionalRawData) - { - DataSources = dataSources; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreConfiguration() - { - } - - /// Data sources. - public IList DataSources { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfigurations.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfigurations.Serialization.cs deleted file mode 100644 index d19e2ee2d10e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfigurations.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 VectorStoreConfigurations : 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(VectorStoreConfigurations)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("name"u8); - writer.WriteStringValue(StoreName); - writer.WritePropertyName("configuration"u8); - writer.WriteObjectValue(StoreConfiguration, options); - 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 - } - } - } - - VectorStoreConfigurations 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(VectorStoreConfigurations)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreConfigurations(document.RootElement, options); - } - - internal static VectorStoreConfigurations DeserializeVectorStoreConfigurations(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - VectorStoreConfiguration configuration = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("configuration"u8)) - { - configuration = VectorStoreConfiguration.DeserializeVectorStoreConfiguration(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreConfigurations(name, configuration, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreConfigurations)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreConfigurations 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 DeserializeVectorStoreConfigurations(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreConfigurations)} 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 VectorStoreConfigurations FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreConfigurations(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/VectorStoreConfigurations.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfigurations.cs deleted file mode 100644 index f03ceff86442..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreConfigurations.cs +++ /dev/null @@ -1,82 +0,0 @@ -// 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 structure, containing the list of vector storage configurations i.e. the list of azure asset IDs. - public partial class VectorStoreConfigurations - { - /// - /// 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 . - /// Name. - /// Configurations. - /// or is null. - public VectorStoreConfigurations(string storeName, VectorStoreConfiguration storeConfiguration) - { - Argument.AssertNotNull(storeName, nameof(storeName)); - Argument.AssertNotNull(storeConfiguration, nameof(storeConfiguration)); - - StoreName = storeName; - StoreConfiguration = storeConfiguration; - } - - /// Initializes a new instance of . - /// Name. - /// Configurations. - /// Keeps track of any properties unknown to the library. - internal VectorStoreConfigurations(string storeName, VectorStoreConfiguration storeConfiguration, IDictionary serializedAdditionalRawData) - { - StoreName = storeName; - StoreConfiguration = storeConfiguration; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreConfigurations() - { - } - - /// Name. - public string StoreName { get; set; } - /// Configurations. - public VectorStoreConfiguration StoreConfiguration { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDataSource.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDataSource.Serialization.cs deleted file mode 100644 index d2e310b499de..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDataSource.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 VectorStoreDataSource : 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(VectorStoreDataSource)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("uri"u8); - writer.WriteStringValue(AssetIdentifier); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(AssetType.ToString()); - 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 - } - } - } - - VectorStoreDataSource 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(VectorStoreDataSource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreDataSource(document.RootElement, options); - } - - internal static VectorStoreDataSource DeserializeVectorStoreDataSource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string uri = default; - VectorStoreDataSourceAssetType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("uri"u8)) - { - uri = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new VectorStoreDataSourceAssetType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreDataSource(uri, type, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreDataSource)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreDataSource 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 DeserializeVectorStoreDataSource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreDataSource)} 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 VectorStoreDataSource FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreDataSource(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/VectorStoreDataSource.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDataSource.cs deleted file mode 100644 index 5752d96eef2f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDataSource.cs +++ /dev/null @@ -1,84 +0,0 @@ -// 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 structure, containing Azure asset URI path and the asset type of the file used as a data source - /// for the enterprise file search. - /// - public partial class VectorStoreDataSource - { - /// - /// 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 . - /// Asset URI. - /// The asset type. - /// is null. - public VectorStoreDataSource(string assetIdentifier, VectorStoreDataSourceAssetType assetType) - { - Argument.AssertNotNull(assetIdentifier, nameof(assetIdentifier)); - - AssetIdentifier = assetIdentifier; - AssetType = assetType; - } - - /// Initializes a new instance of . - /// Asset URI. - /// The asset type. - /// Keeps track of any properties unknown to the library. - internal VectorStoreDataSource(string assetIdentifier, VectorStoreDataSourceAssetType assetType, IDictionary serializedAdditionalRawData) - { - AssetIdentifier = assetIdentifier; - AssetType = assetType; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreDataSource() - { - } - - /// Asset URI. - public string AssetIdentifier { get; set; } - /// The asset type. - public VectorStoreDataSourceAssetType AssetType { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDataSourceAssetType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDataSourceAssetType.cs deleted file mode 100644 index 8a121dac0aef..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDataSourceAssetType.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// - /// Type of vector storage asset. Asset type may be a uri_asset, in this case it should contain asset URI ID, - /// in the case of id_asset it should contain the data ID. - /// - public readonly partial struct VectorStoreDataSourceAssetType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreDataSourceAssetType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string UriAssetValue = "uri_asset"; - private const string IdAssetValue = "id_asset"; - - /// Azure URI. - public static VectorStoreDataSourceAssetType UriAsset { get; } = new VectorStoreDataSourceAssetType(UriAssetValue); - /// The data ID. - public static VectorStoreDataSourceAssetType IdAsset { get; } = new VectorStoreDataSourceAssetType(IdAssetValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreDataSourceAssetType left, VectorStoreDataSourceAssetType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreDataSourceAssetType left, VectorStoreDataSourceAssetType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreDataSourceAssetType(string value) => new VectorStoreDataSourceAssetType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreDataSourceAssetType other && Equals(other); - /// - public bool Equals(VectorStoreDataSourceAssetType 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDeletionStatus.Serialization.cs deleted file mode 100644 index ea7f7daf1464..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDeletionStatus.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 VectorStoreDeletionStatus : 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(VectorStoreDeletionStatus)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - 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 - } - } - } - - VectorStoreDeletionStatus 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(VectorStoreDeletionStatus)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreDeletionStatus(document.RootElement, options); - } - - internal static VectorStoreDeletionStatus DeserializeVectorStoreDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - bool deleted = default; - VectorStoreDeletionStatusObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new VectorStoreDeletionStatusObject(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreDeletionStatus(id, deleted, @object, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreDeletionStatus 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 DeserializeVectorStoreDeletionStatus(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} 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 VectorStoreDeletionStatus FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreDeletionStatus(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/VectorStoreDeletionStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDeletionStatus.cs deleted file mode 100644 index 321e74552779..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDeletionStatus.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Response object for deleting a vector store. - public partial class VectorStoreDeletionStatus - { - /// - /// 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 ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// is null. - internal VectorStoreDeletionStatus(string id, bool deleted) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - Deleted = deleted; - } - - /// Initializes a new instance of . - /// The ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// The object type, which is always 'vector_store.deleted'. - /// Keeps track of any properties unknown to the library. - internal VectorStoreDeletionStatus(string id, bool deleted, VectorStoreDeletionStatusObject @object, IDictionary serializedAdditionalRawData) - { - Id = id; - Deleted = deleted; - Object = @object; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreDeletionStatus() - { - } - - /// The ID of the resource specified for deletion. - public string Id { get; } - /// A value indicating whether deletion was successful. - public bool Deleted { get; } - /// The object type, which is always 'vector_store.deleted'. - public VectorStoreDeletionStatusObject Object { get; } = VectorStoreDeletionStatusObject.VectorStoreDeleted; - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDeletionStatusObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDeletionStatusObject.cs deleted file mode 100644 index 3390947ca448..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreDeletionStatusObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The VectorStoreDeletionStatus_object. - public readonly partial struct VectorStoreDeletionStatusObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreDeletionStatusObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string VectorStoreDeletedValue = "vector_store.deleted"; - - /// vector_store.deleted. - public static VectorStoreDeletionStatusObject VectorStoreDeleted { get; } = new VectorStoreDeletionStatusObject(VectorStoreDeletedValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreDeletionStatusObject left, VectorStoreDeletionStatusObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreDeletionStatusObject left, VectorStoreDeletionStatusObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreDeletionStatusObject(string value) => new VectorStoreDeletionStatusObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreDeletionStatusObject other && Equals(other); - /// - public bool Equals(VectorStoreDeletionStatusObject 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreExpirationPolicy.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreExpirationPolicy.Serialization.cs deleted file mode 100644 index 0c56e4fcd77c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreExpirationPolicy.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 VectorStoreExpirationPolicy : 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(VectorStoreExpirationPolicy)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("anchor"u8); - writer.WriteStringValue(Anchor.ToString()); - writer.WritePropertyName("days"u8); - writer.WriteNumberValue(Days); - 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 - } - } - } - - VectorStoreExpirationPolicy 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(VectorStoreExpirationPolicy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); - } - - internal static VectorStoreExpirationPolicy DeserializeVectorStoreExpirationPolicy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - VectorStoreExpirationPolicyAnchor anchor = default; - int days = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("anchor"u8)) - { - anchor = new VectorStoreExpirationPolicyAnchor(property.Value.GetString()); - continue; - } - if (property.NameEquals("days"u8)) - { - days = property.Value.GetInt32(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreExpirationPolicy(anchor, days, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreExpirationPolicy 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 DeserializeVectorStoreExpirationPolicy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} 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 VectorStoreExpirationPolicy FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreExpirationPolicy(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/VectorStoreExpirationPolicy.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreExpirationPolicy.cs deleted file mode 100644 index 3db18fe4a917..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreExpirationPolicy.cs +++ /dev/null @@ -1,78 +0,0 @@ -// 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 expiration policy for a vector store. - public partial class VectorStoreExpirationPolicy - { - /// - /// 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 . - /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. - /// The anchor timestamp after which the expiration policy applies. - public VectorStoreExpirationPolicy(VectorStoreExpirationPolicyAnchor anchor, int days) - { - Anchor = anchor; - Days = days; - } - - /// Initializes a new instance of . - /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. - /// The anchor timestamp after which the expiration policy applies. - /// Keeps track of any properties unknown to the library. - internal VectorStoreExpirationPolicy(VectorStoreExpirationPolicyAnchor anchor, int days, IDictionary serializedAdditionalRawData) - { - Anchor = anchor; - Days = days; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreExpirationPolicy() - { - } - - /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. - public VectorStoreExpirationPolicyAnchor Anchor { get; set; } - /// The anchor timestamp after which the expiration policy applies. - public int Days { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreExpirationPolicyAnchor.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreExpirationPolicyAnchor.cs deleted file mode 100644 index 1bf85570a885..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreExpirationPolicyAnchor.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Describes the relationship between the days and the expiration of this vector store. - public readonly partial struct VectorStoreExpirationPolicyAnchor : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreExpirationPolicyAnchor(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string LastActiveAtValue = "last_active_at"; - - /// The expiration policy is based on the last time the vector store was active. - public static VectorStoreExpirationPolicyAnchor LastActiveAt { get; } = new VectorStoreExpirationPolicyAnchor(LastActiveAtValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreExpirationPolicyAnchor left, VectorStoreExpirationPolicyAnchor right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreExpirationPolicyAnchor left, VectorStoreExpirationPolicyAnchor right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreExpirationPolicyAnchor(string value) => new VectorStoreExpirationPolicyAnchor(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreExpirationPolicyAnchor other && Equals(other); - /// - public bool Equals(VectorStoreExpirationPolicyAnchor 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFile.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFile.Serialization.cs deleted file mode 100644 index 53215be55eaf..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFile.Serialization.cs +++ /dev/null @@ -1,219 +0,0 @@ -// 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 VectorStoreFile : 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(VectorStoreFile)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("usage_bytes"u8); - writer.WriteNumberValue(UsageBytes); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - writer.WritePropertyName("vector_store_id"u8); - writer.WriteStringValue(VectorStoreId); - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); - if (LastError != null) - { - writer.WritePropertyName("last_error"u8); - writer.WriteObjectValue(LastError, options); - } - else - { - writer.WriteNull("last_error"); - } - writer.WritePropertyName("chunking_strategy"u8); - writer.WriteObjectValue(ChunkingStrategy, options); - 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 - } - } - } - - VectorStoreFile 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(VectorStoreFile)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreFile(document.RootElement, options); - } - - internal static VectorStoreFile DeserializeVectorStoreFile(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - VectorStoreFileObject @object = default; - int usageBytes = default; - DateTimeOffset createdAt = default; - string vectorStoreId = default; - VectorStoreFileStatus status = default; - VectorStoreFileError lastError = default; - VectorStoreChunkingStrategyResponse chunkingStrategy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new VectorStoreFileObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("usage_bytes"u8)) - { - usageBytes = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("vector_store_id"u8)) - { - vectorStoreId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new VectorStoreFileStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("last_error"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastError = null; - continue; - } - lastError = VectorStoreFileError.DeserializeVectorStoreFileError(property.Value, options); - continue; - } - if (property.NameEquals("chunking_strategy"u8)) - { - chunkingStrategy = VectorStoreChunkingStrategyResponse.DeserializeVectorStoreChunkingStrategyResponse(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreFile( - id, - @object, - usageBytes, - createdAt, - vectorStoreId, - status, - lastError, - chunkingStrategy, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreFile)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreFile 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 DeserializeVectorStoreFile(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreFile)} 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 VectorStoreFile FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreFile(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/VectorStoreFile.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFile.cs deleted file mode 100644 index 951239eb4d06..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFile.cs +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Description of a file attached to a vector store. - public partial class VectorStoreFile - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// - /// The total vector store usage in bytes. Note that this may be different from the original file - /// size. - /// - /// The Unix timestamp (in seconds) for when the vector store file was created. - /// The ID of the vector store that the file is attached to. - /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. - /// The last error associated with this vector store file. Will be `null` if there are no errors. - /// - /// The strategy used to chunk the file. - /// 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 . - /// - /// , or is null. - internal VectorStoreFile(string id, int usageBytes, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileStatus status, VectorStoreFileError lastError, VectorStoreChunkingStrategyResponse chunkingStrategy) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(chunkingStrategy, nameof(chunkingStrategy)); - - Id = id; - UsageBytes = usageBytes; - CreatedAt = createdAt; - VectorStoreId = vectorStoreId; - Status = status; - LastError = lastError; - ChunkingStrategy = chunkingStrategy; - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always `vector_store.file`. - /// - /// The total vector store usage in bytes. Note that this may be different from the original file - /// size. - /// - /// The Unix timestamp (in seconds) for when the vector store file was created. - /// The ID of the vector store that the file is attached to. - /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. - /// The last error associated with this vector store file. Will be `null` if there are no errors. - /// - /// The strategy used to chunk the file. - /// 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 . - /// - /// Keeps track of any properties unknown to the library. - internal VectorStoreFile(string id, VectorStoreFileObject @object, int usageBytes, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileStatus status, VectorStoreFileError lastError, VectorStoreChunkingStrategyResponse chunkingStrategy, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - UsageBytes = usageBytes; - CreatedAt = createdAt; - VectorStoreId = vectorStoreId; - Status = status; - LastError = lastError; - ChunkingStrategy = chunkingStrategy; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreFile() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - /// The object type, which is always `vector_store.file`. - public VectorStoreFileObject Object { get; } = VectorStoreFileObject.VectorStoreFile; - - /// - /// The total vector store usage in bytes. Note that this may be different from the original file - /// size. - /// - public int UsageBytes { get; } - /// The Unix timestamp (in seconds) for when the vector store file was created. - public DateTimeOffset CreatedAt { get; } - /// The ID of the vector store that the file is attached to. - public string VectorStoreId { get; } - /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. - public VectorStoreFileStatus Status { get; } - /// The last error associated with this vector store file. Will be `null` if there are no errors. - public VectorStoreFileError LastError { get; } - /// - /// The strategy used to chunk the file. - /// 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 VectorStoreChunkingStrategyResponse ChunkingStrategy { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatch.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatch.Serialization.cs deleted file mode 100644 index e0642ce6bcd6..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatch.Serialization.cs +++ /dev/null @@ -1,189 +0,0 @@ -// 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 VectorStoreFileBatch : 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(VectorStoreFileBatch)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - writer.WritePropertyName("vector_store_id"u8); - writer.WriteStringValue(VectorStoreId); - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); - writer.WritePropertyName("file_counts"u8); - writer.WriteObjectValue(FileCounts, options); - 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 - } - } - } - - VectorStoreFileBatch 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(VectorStoreFileBatch)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreFileBatch(document.RootElement, options); - } - - internal static VectorStoreFileBatch DeserializeVectorStoreFileBatch(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - VectorStoreFileBatchObject @object = default; - DateTimeOffset createdAt = default; - string vectorStoreId = default; - VectorStoreFileBatchStatus status = default; - VectorStoreFileCount fileCounts = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new VectorStoreFileBatchObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("vector_store_id"u8)) - { - vectorStoreId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new VectorStoreFileBatchStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("file_counts"u8)) - { - fileCounts = VectorStoreFileCount.DeserializeVectorStoreFileCount(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreFileBatch( - id, - @object, - createdAt, - vectorStoreId, - status, - fileCounts, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreFileBatch 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 DeserializeVectorStoreFileBatch(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreFileBatch)} 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 VectorStoreFileBatch FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreFileBatch(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/VectorStoreFileBatch.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatch.cs deleted file mode 100644 index 88ff32d39ded..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatch.cs +++ /dev/null @@ -1,106 +0,0 @@ -// 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 batch of files attached to a vector store. - public partial class VectorStoreFileBatch - { - /// - /// 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 identifier, which can be referenced in API endpoints. - /// The Unix timestamp (in seconds) for when the vector store files batch was created. - /// The ID of the vector store that the file is attached to. - /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. - /// Files count grouped by status processed or being processed by this vector store. - /// , or is null. - internal VectorStoreFileBatch(string id, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileBatchStatus status, VectorStoreFileCount fileCounts) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(fileCounts, nameof(fileCounts)); - - Id = id; - CreatedAt = createdAt; - VectorStoreId = vectorStoreId; - Status = status; - FileCounts = fileCounts; - } - - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always `vector_store.file_batch`. - /// The Unix timestamp (in seconds) for when the vector store files batch was created. - /// The ID of the vector store that the file is attached to. - /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. - /// Files count grouped by status processed or being processed by this vector store. - /// Keeps track of any properties unknown to the library. - internal VectorStoreFileBatch(string id, VectorStoreFileBatchObject @object, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileBatchStatus status, VectorStoreFileCount fileCounts, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - VectorStoreId = vectorStoreId; - Status = status; - FileCounts = fileCounts; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreFileBatch() - { - } - - /// The identifier, which can be referenced in API endpoints. - public string Id { get; } - /// The object type, which is always `vector_store.file_batch`. - public VectorStoreFileBatchObject Object { get; } = VectorStoreFileBatchObject.VectorStoreFilesBatch; - - /// The Unix timestamp (in seconds) for when the vector store files batch was created. - public DateTimeOffset CreatedAt { get; } - /// The ID of the vector store that the file is attached to. - public string VectorStoreId { get; } - /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. - public VectorStoreFileBatchStatus Status { get; } - /// Files count grouped by status processed or being processed by this vector store. - public VectorStoreFileCount FileCounts { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatchObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatchObject.cs deleted file mode 100644 index 5e0f2c56022f..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatchObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The VectorStoreFileBatch_object. - public readonly partial struct VectorStoreFileBatchObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreFileBatchObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string VectorStoreFilesBatchValue = "vector_store.files_batch"; - - /// vector_store.files_batch. - public static VectorStoreFileBatchObject VectorStoreFilesBatch { get; } = new VectorStoreFileBatchObject(VectorStoreFilesBatchValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreFileBatchObject left, VectorStoreFileBatchObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreFileBatchObject left, VectorStoreFileBatchObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreFileBatchObject(string value) => new VectorStoreFileBatchObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileBatchObject other && Equals(other); - /// - public bool Equals(VectorStoreFileBatchObject 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatchStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatchStatus.cs deleted file mode 100644 index fc774681056e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileBatchStatus.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The status of the vector store file batch. - public readonly partial struct VectorStoreFileBatchStatus : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreFileBatchStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string CompletedValue = "completed"; - private const string CancelledValue = "cancelled"; - private const string FailedValue = "failed"; - - /// The vector store is still processing this file batch. - public static VectorStoreFileBatchStatus InProgress { get; } = new VectorStoreFileBatchStatus(InProgressValue); - /// the vector store file batch is ready for use. - public static VectorStoreFileBatchStatus Completed { get; } = new VectorStoreFileBatchStatus(CompletedValue); - /// The vector store file batch was cancelled. - public static VectorStoreFileBatchStatus Cancelled { get; } = new VectorStoreFileBatchStatus(CancelledValue); - /// The vector store file batch failed to process. - public static VectorStoreFileBatchStatus Failed { get; } = new VectorStoreFileBatchStatus(FailedValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreFileBatchStatus left, VectorStoreFileBatchStatus right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreFileBatchStatus left, VectorStoreFileBatchStatus right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreFileBatchStatus(string value) => new VectorStoreFileBatchStatus(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileBatchStatus other && Equals(other); - /// - public bool Equals(VectorStoreFileBatchStatus 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileCount.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileCount.Serialization.cs deleted file mode 100644 index 220476d03216..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileCount.Serialization.cs +++ /dev/null @@ -1,180 +0,0 @@ -// 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 VectorStoreFileCount : 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(VectorStoreFileCount)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("in_progress"u8); - writer.WriteNumberValue(InProgress); - writer.WritePropertyName("completed"u8); - writer.WriteNumberValue(Completed); - writer.WritePropertyName("failed"u8); - writer.WriteNumberValue(Failed); - writer.WritePropertyName("cancelled"u8); - writer.WriteNumberValue(Cancelled); - writer.WritePropertyName("total"u8); - writer.WriteNumberValue(Total); - 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 - } - } - } - - VectorStoreFileCount 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(VectorStoreFileCount)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreFileCount(document.RootElement, options); - } - - internal static VectorStoreFileCount DeserializeVectorStoreFileCount(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int inProgress = default; - int completed = default; - int failed = default; - int cancelled = default; - int total = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("in_progress"u8)) - { - inProgress = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("completed"u8)) - { - completed = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("failed"u8)) - { - failed = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("cancelled"u8)) - { - cancelled = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("total"u8)) - { - total = property.Value.GetInt32(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreFileCount( - inProgress, - completed, - failed, - cancelled, - total, - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreFileCount 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 DeserializeVectorStoreFileCount(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreFileCount)} 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 VectorStoreFileCount FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreFileCount(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/VectorStoreFileCount.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileCount.cs deleted file mode 100644 index c80206511a02..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileCount.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Counts of files processed or being processed by this vector store grouped by status. - public partial class VectorStoreFileCount - { - /// - /// 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 number of files that are currently being processed. - /// The number of files that have been successfully processed. - /// The number of files that have failed to process. - /// The number of files that were cancelled. - /// The total number of files. - internal VectorStoreFileCount(int inProgress, int completed, int failed, int cancelled, int total) - { - InProgress = inProgress; - Completed = completed; - Failed = failed; - Cancelled = cancelled; - Total = total; - } - - /// Initializes a new instance of . - /// The number of files that are currently being processed. - /// The number of files that have been successfully processed. - /// The number of files that have failed to process. - /// The number of files that were cancelled. - /// The total number of files. - /// Keeps track of any properties unknown to the library. - internal VectorStoreFileCount(int inProgress, int completed, int failed, int cancelled, int total, IDictionary serializedAdditionalRawData) - { - InProgress = inProgress; - Completed = completed; - Failed = failed; - Cancelled = cancelled; - Total = total; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreFileCount() - { - } - - /// The number of files that are currently being processed. - public int InProgress { get; } - /// The number of files that have been successfully processed. - public int Completed { get; } - /// The number of files that have failed to process. - public int Failed { get; } - /// The number of files that were cancelled. - public int Cancelled { get; } - /// The total number of files. - public int Total { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs deleted file mode 100644 index 84760f60ae97..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs +++ /dev/null @@ -1,158 +0,0 @@ -// 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 VectorStoreFileDeletionStatus : 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(VectorStoreFileDeletionStatus)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - 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 - } - } - } - - VectorStoreFileDeletionStatus 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(VectorStoreFileDeletionStatus)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreFileDeletionStatus(document.RootElement, options); - } - - internal static VectorStoreFileDeletionStatus DeserializeVectorStoreFileDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - bool deleted = default; - VectorStoreFileDeletionStatusObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new VectorStoreFileDeletionStatusObject(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreFileDeletionStatus(id, deleted, @object, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreFileDeletionStatus 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 DeserializeVectorStoreFileDeletionStatus(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} 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 VectorStoreFileDeletionStatus FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreFileDeletionStatus(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/VectorStoreFileDeletionStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileDeletionStatus.cs deleted file mode 100644 index 482e595895bd..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileDeletionStatus.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Response object for deleting a vector store file relationship. - public partial class VectorStoreFileDeletionStatus - { - /// - /// 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 ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// is null. - internal VectorStoreFileDeletionStatus(string id, bool deleted) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - Deleted = deleted; - } - - /// Initializes a new instance of . - /// The ID of the resource specified for deletion. - /// A value indicating whether deletion was successful. - /// The object type, which is always 'vector_store.deleted'. - /// Keeps track of any properties unknown to the library. - internal VectorStoreFileDeletionStatus(string id, bool deleted, VectorStoreFileDeletionStatusObject @object, IDictionary serializedAdditionalRawData) - { - Id = id; - Deleted = deleted; - Object = @object; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreFileDeletionStatus() - { - } - - /// The ID of the resource specified for deletion. - public string Id { get; } - /// A value indicating whether deletion was successful. - public bool Deleted { get; } - /// The object type, which is always 'vector_store.deleted'. - public VectorStoreFileDeletionStatusObject Object { get; } = VectorStoreFileDeletionStatusObject.VectorStoreFileDeleted; - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileDeletionStatusObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileDeletionStatusObject.cs deleted file mode 100644 index e504fb729bcc..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileDeletionStatusObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The VectorStoreFileDeletionStatus_object. - public readonly partial struct VectorStoreFileDeletionStatusObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreFileDeletionStatusObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string VectorStoreFileDeletedValue = "vector_store.file.deleted"; - - /// vector_store.file.deleted. - public static VectorStoreFileDeletionStatusObject VectorStoreFileDeleted { get; } = new VectorStoreFileDeletionStatusObject(VectorStoreFileDeletedValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreFileDeletionStatusObject left, VectorStoreFileDeletionStatusObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreFileDeletionStatusObject left, VectorStoreFileDeletionStatusObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreFileDeletionStatusObject(string value) => new VectorStoreFileDeletionStatusObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileDeletionStatusObject other && Equals(other); - /// - public bool Equals(VectorStoreFileDeletionStatusObject 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileError.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileError.Serialization.cs deleted file mode 100644 index 83acd520401c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileError.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 VectorStoreFileError : 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(VectorStoreFileError)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code.ToString()); - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - 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 - } - } - } - - VectorStoreFileError 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(VectorStoreFileError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreFileError(document.RootElement, options); - } - - internal static VectorStoreFileError DeserializeVectorStoreFileError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - VectorStoreFileErrorCode code = default; - string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code"u8)) - { - code = new VectorStoreFileErrorCode(property.Value.GetString()); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreFileError(code, message, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreFileError 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 DeserializeVectorStoreFileError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreFileError)} 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 VectorStoreFileError FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreFileError(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/VectorStoreFileError.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileError.cs deleted file mode 100644 index 05eefeb61296..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileError.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Details on the error that may have occurred while processing a file for this vector store. - public partial class VectorStoreFileError - { - /// - /// 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 . - /// One of `server_error` or `rate_limit_exceeded`. - /// A human-readable description of the error. - /// is null. - internal VectorStoreFileError(VectorStoreFileErrorCode code, string message) - { - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - } - - /// Initializes a new instance of . - /// One of `server_error` or `rate_limit_exceeded`. - /// A human-readable description of the error. - /// Keeps track of any properties unknown to the library. - internal VectorStoreFileError(VectorStoreFileErrorCode code, string message, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreFileError() - { - } - - /// One of `server_error` or `rate_limit_exceeded`. - public VectorStoreFileErrorCode Code { get; } - /// A human-readable description of the error. - public string Message { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileErrorCode.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileErrorCode.cs deleted file mode 100644 index 1c57f06e4aa8..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileErrorCode.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Error code variants for vector store file processing. - public readonly partial struct VectorStoreFileErrorCode : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreFileErrorCode(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ServerErrorValue = "server_error"; - private const string InvalidFileValue = "invalid_file"; - private const string UnsupportedFileValue = "unsupported_file"; - - /// An server error occurred. - public static VectorStoreFileErrorCode ServerError { get; } = new VectorStoreFileErrorCode(ServerErrorValue); - /// The file is not valid. - public static VectorStoreFileErrorCode InvalidFile { get; } = new VectorStoreFileErrorCode(InvalidFileValue); - /// The file is of unsupported type. - public static VectorStoreFileErrorCode UnsupportedFile { get; } = new VectorStoreFileErrorCode(UnsupportedFileValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreFileErrorCode left, VectorStoreFileErrorCode right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreFileErrorCode left, VectorStoreFileErrorCode right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreFileErrorCode(string value) => new VectorStoreFileErrorCode(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileErrorCode other && Equals(other); - /// - public bool Equals(VectorStoreFileErrorCode 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileObject.cs deleted file mode 100644 index 193150fcabda..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The VectorStoreFile_object. - public readonly partial struct VectorStoreFileObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreFileObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string VectorStoreFileValue = "vector_store.file"; - - /// vector_store.file. - public static VectorStoreFileObject VectorStoreFile { get; } = new VectorStoreFileObject(VectorStoreFileValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreFileObject left, VectorStoreFileObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreFileObject left, VectorStoreFileObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreFileObject(string value) => new VectorStoreFileObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileObject other && Equals(other); - /// - public bool Equals(VectorStoreFileObject 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileStatus.cs deleted file mode 100644 index e82d7daa48b4..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileStatus.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Vector store file status. - public readonly partial struct VectorStoreFileStatus : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreFileStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string CompletedValue = "completed"; - private const string FailedValue = "failed"; - private const string CancelledValue = "cancelled"; - - /// The file is currently being processed. - public static VectorStoreFileStatus InProgress { get; } = new VectorStoreFileStatus(InProgressValue); - /// The file has been successfully processed. - public static VectorStoreFileStatus Completed { get; } = new VectorStoreFileStatus(CompletedValue); - /// The file has failed to process. - public static VectorStoreFileStatus Failed { get; } = new VectorStoreFileStatus(FailedValue); - /// The file was cancelled. - public static VectorStoreFileStatus Cancelled { get; } = new VectorStoreFileStatus(CancelledValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreFileStatus left, VectorStoreFileStatus right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreFileStatus left, VectorStoreFileStatus right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreFileStatus(string value) => new VectorStoreFileStatus(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileStatus other && Equals(other); - /// - public bool Equals(VectorStoreFileStatus 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileStatusFilter.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileStatusFilter.cs deleted file mode 100644 index db1de56806d0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreFileStatusFilter.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Query parameter filter for vector store file retrieval endpoint. - public readonly partial struct VectorStoreFileStatusFilter : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreFileStatusFilter(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string CompletedValue = "completed"; - private const string FailedValue = "failed"; - private const string CancelledValue = "cancelled"; - - /// Retrieve only files that are currently being processed. - public static VectorStoreFileStatusFilter InProgress { get; } = new VectorStoreFileStatusFilter(InProgressValue); - /// Retrieve only files that have been successfully processed. - public static VectorStoreFileStatusFilter Completed { get; } = new VectorStoreFileStatusFilter(CompletedValue); - /// Retrieve only files that have failed to process. - public static VectorStoreFileStatusFilter Failed { get; } = new VectorStoreFileStatusFilter(FailedValue); - /// Retrieve only files that were cancelled. - public static VectorStoreFileStatusFilter Cancelled { get; } = new VectorStoreFileStatusFilter(CancelledValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreFileStatusFilter(string value) => new VectorStoreFileStatusFilter(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileStatusFilter other && Equals(other); - /// - public bool Equals(VectorStoreFileStatusFilter 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreObject.cs deleted file mode 100644 index ca48dc13afdc..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// The VectorStore_object. - public readonly partial struct VectorStoreObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string VectorStoreValue = "vector_store"; - - /// vector_store. - public static VectorStoreObject VectorStore { get; } = new VectorStoreObject(VectorStoreValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreObject left, VectorStoreObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreObject left, VectorStoreObject right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreObject(string value) => new VectorStoreObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreObject other && Equals(other); - /// - public bool Equals(VectorStoreObject 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/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs deleted file mode 100644 index f3502ef55df9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// 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 VectorStoreStaticChunkingStrategyOptions : 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(VectorStoreStaticChunkingStrategyOptions)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("max_chunk_size_tokens"u8); - writer.WriteNumberValue(MaxChunkSizeTokens); - writer.WritePropertyName("chunk_overlap_tokens"u8); - writer.WriteNumberValue(ChunkOverlapTokens); - 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 - } - } - } - - VectorStoreStaticChunkingStrategyOptions 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(VectorStoreStaticChunkingStrategyOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreStaticChunkingStrategyOptions(document.RootElement, options); - } - - internal static VectorStoreStaticChunkingStrategyOptions DeserializeVectorStoreStaticChunkingStrategyOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int maxChunkSizeTokens = default; - int chunkOverlapTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("max_chunk_size_tokens"u8)) - { - maxChunkSizeTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("chunk_overlap_tokens"u8)) - { - chunkOverlapTokens = property.Value.GetInt32(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreStaticChunkingStrategyOptions(maxChunkSizeTokens, chunkOverlapTokens, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreStaticChunkingStrategyOptions 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 DeserializeVectorStoreStaticChunkingStrategyOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} 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 VectorStoreStaticChunkingStrategyOptions FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreStaticChunkingStrategyOptions(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/VectorStoreStaticChunkingStrategyOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs deleted file mode 100644 index 422806be34d5..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// Options to configure a vector store static chunking strategy. - public partial class VectorStoreStaticChunkingStrategyOptions - { - /// - /// 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 maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. - /// - /// The number of tokens that overlap between chunks. The default value is 400. - /// Note that the overlap must not exceed half of max_chunk_size_tokens. - /// - public VectorStoreStaticChunkingStrategyOptions(int maxChunkSizeTokens, int chunkOverlapTokens) - { - MaxChunkSizeTokens = maxChunkSizeTokens; - ChunkOverlapTokens = chunkOverlapTokens; - } - - /// Initializes a new instance of . - /// The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. - /// - /// The number of tokens that overlap between chunks. The default value is 400. - /// Note that the overlap must not exceed half of max_chunk_size_tokens. - /// - /// Keeps track of any properties unknown to the library. - internal VectorStoreStaticChunkingStrategyOptions(int maxChunkSizeTokens, int chunkOverlapTokens, IDictionary serializedAdditionalRawData) - { - MaxChunkSizeTokens = maxChunkSizeTokens; - ChunkOverlapTokens = chunkOverlapTokens; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreStaticChunkingStrategyOptions() - { - } - - /// The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. - public int MaxChunkSizeTokens { get; set; } - /// - /// The number of tokens that overlap between chunks. The default value is 400. - /// Note that the overlap must not exceed half of max_chunk_size_tokens. - /// - public int ChunkOverlapTokens { get; set; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs deleted file mode 100644 index 05de1791cbe9..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 VectorStoreStaticChunkingStrategyRequest : 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(VectorStoreStaticChunkingStrategyRequest)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("static"u8); - writer.WriteObjectValue(Static, options); - } - - VectorStoreStaticChunkingStrategyRequest 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(VectorStoreStaticChunkingStrategyRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreStaticChunkingStrategyRequest(document.RootElement, options); - } - - internal static VectorStoreStaticChunkingStrategyRequest DeserializeVectorStoreStaticChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - VectorStoreStaticChunkingStrategyOptions @static = default; - VectorStoreChunkingStrategyRequestType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("static"u8)) - { - @static = VectorStoreStaticChunkingStrategyOptions.DeserializeVectorStoreStaticChunkingStrategyOptions(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreStaticChunkingStrategyRequest(type, serializedAdditionalRawData, @static); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreStaticChunkingStrategyRequest 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 DeserializeVectorStoreStaticChunkingStrategyRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} 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 VectorStoreStaticChunkingStrategyRequest FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreStaticChunkingStrategyRequest(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/VectorStoreStaticChunkingStrategyRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs deleted file mode 100644 index f310b50f5a22..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 statically configured chunking strategy. - public partial class VectorStoreStaticChunkingStrategyRequest : VectorStoreChunkingStrategyRequest - { - /// Initializes a new instance of . - /// The options for the static chunking strategy. - /// is null. - public VectorStoreStaticChunkingStrategyRequest(VectorStoreStaticChunkingStrategyOptions @static) - { - Argument.AssertNotNull(@static, nameof(@static)); - - Type = VectorStoreChunkingStrategyRequestType.Static; - Static = @static; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The options for the static chunking strategy. - internal VectorStoreStaticChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData, VectorStoreStaticChunkingStrategyOptions @static) : base(type, serializedAdditionalRawData) - { - Static = @static; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreStaticChunkingStrategyRequest() - { - } - - /// The options for the static chunking strategy. - public VectorStoreStaticChunkingStrategyOptions Static { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs deleted file mode 100644 index aa186d05c9f3..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// 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 VectorStoreStaticChunkingStrategyResponse : 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(VectorStoreStaticChunkingStrategyResponse)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("static"u8); - writer.WriteObjectValue(Static, options); - } - - VectorStoreStaticChunkingStrategyResponse 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(VectorStoreStaticChunkingStrategyResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreStaticChunkingStrategyResponse(document.RootElement, options); - } - - internal static VectorStoreStaticChunkingStrategyResponse DeserializeVectorStoreStaticChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - VectorStoreStaticChunkingStrategyOptions @static = default; - VectorStoreChunkingStrategyResponseType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("static"u8)) - { - @static = VectorStoreStaticChunkingStrategyOptions.DeserializeVectorStoreStaticChunkingStrategyOptions(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreStaticChunkingStrategyResponse(type, serializedAdditionalRawData, @static); - } - - 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support writing '{options.Format}' format."); - } - } - - VectorStoreStaticChunkingStrategyResponse 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 DeserializeVectorStoreStaticChunkingStrategyResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} 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 VectorStoreStaticChunkingStrategyResponse FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeVectorStoreStaticChunkingStrategyResponse(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/VectorStoreStaticChunkingStrategyResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs deleted file mode 100644 index fcbde230275c..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 statically configured chunking strategy. - public partial class VectorStoreStaticChunkingStrategyResponse : VectorStoreChunkingStrategyResponse - { - /// Initializes a new instance of . - /// The options for the static chunking strategy. - /// is null. - internal VectorStoreStaticChunkingStrategyResponse(VectorStoreStaticChunkingStrategyOptions @static) - { - Argument.AssertNotNull(@static, nameof(@static)); - - Type = VectorStoreChunkingStrategyResponseType.Static; - Static = @static; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - /// The options for the static chunking strategy. - internal VectorStoreStaticChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData, VectorStoreStaticChunkingStrategyOptions @static) : base(type, serializedAdditionalRawData) - { - Static = @static; - } - - /// Initializes a new instance of for deserialization. - internal VectorStoreStaticChunkingStrategyResponse() - { - } - - /// The options for the static chunking strategy. - public VectorStoreStaticChunkingStrategyOptions Static { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStatus.cs deleted file mode 100644 index 30cc174ef910..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/VectorStoreStatus.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// Vector store possible status. - public readonly partial struct VectorStoreStatus : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public VectorStoreStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ExpiredValue = "expired"; - private const string InProgressValue = "in_progress"; - private const string CompletedValue = "completed"; - - /// expired status indicates that this vector store has expired and is no longer available for use. - public static VectorStoreStatus Expired { get; } = new VectorStoreStatus(ExpiredValue); - /// in_progress status indicates that this vector store is still processing files. - public static VectorStoreStatus InProgress { get; } = new VectorStoreStatus(InProgressValue); - /// completed status indicates that this vector store is ready for use. - public static VectorStoreStatus Completed { get; } = new VectorStoreStatus(CompletedValue); - /// Determines if two values are the same. - public static bool operator ==(VectorStoreStatus left, VectorStoreStatus right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(VectorStoreStatus left, VectorStoreStatus right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator VectorStoreStatus(string value) => new VectorStoreStatus(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreStatus other && Equals(other); - /// - public bool Equals(VectorStoreStatus 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/sdk/ai/Azure.AI.Projects/src/Generated/WeekDays.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WeekDays.cs deleted file mode 100644 index 000ae68ad211..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/WeekDays.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Projects -{ - /// WeekDay of the schedule - Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. - public readonly partial struct WeekDays : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public WeekDays(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string MondayValue = "Monday"; - private const string TuesdayValue = "Tuesday"; - private const string WednesdayValue = "Wednesday"; - private const string ThursdayValue = "Thursday"; - private const string FridayValue = "Friday"; - private const string SaturdayValue = "Saturday"; - private const string SundayValue = "Sunday"; - - /// Monday. - public static WeekDays Monday { get; } = new WeekDays(MondayValue); - /// Tuesday. - public static WeekDays Tuesday { get; } = new WeekDays(TuesdayValue); - /// Wednesday. - public static WeekDays Wednesday { get; } = new WeekDays(WednesdayValue); - /// Thursday. - public static WeekDays Thursday { get; } = new WeekDays(ThursdayValue); - /// Friday. - public static WeekDays Friday { get; } = new WeekDays(FridayValue); - /// Saturday. - public static WeekDays Saturday { get; } = new WeekDays(SaturdayValue); - /// Sunday. - public static WeekDays Sunday { get; } = new WeekDays(SundayValue); - /// Determines if two values are the same. - public static bool operator ==(WeekDays left, WeekDays right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(WeekDays left, WeekDays right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator WeekDays(string value) => new WeekDays(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is WeekDays other && Equals(other); - /// - public bool Equals(WeekDays 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/sdk/ai/Azure.AI.Projects/src/Generated/WorkspaceProperties.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WorkspaceProperties.Serialization.cs deleted file mode 100644 index 1107e43997d0..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/WorkspaceProperties.Serialization.cs +++ /dev/null @@ -1,142 +0,0 @@ -// 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 WorkspaceProperties : 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(WorkspaceProperties)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("applicationInsights"u8); - writer.WriteStringValue(ApplicationInsights); - 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 - } - } - } - - WorkspaceProperties 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(WorkspaceProperties)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeWorkspaceProperties(document.RootElement, options); - } - - internal static WorkspaceProperties DeserializeWorkspaceProperties(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string applicationInsights = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("applicationInsights"u8)) - { - applicationInsights = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new WorkspaceProperties(applicationInsights, 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, AzureAIProjectsContext.Default); - default: - throw new FormatException($"The model {nameof(WorkspaceProperties)} does not support writing '{options.Format}' format."); - } - } - - WorkspaceProperties 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 DeserializeWorkspaceProperties(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(WorkspaceProperties)} 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 WorkspaceProperties FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeWorkspaceProperties(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/WorkspaceProperties.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WorkspaceProperties.cs deleted file mode 100644 index b7f2db20ac2e..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/WorkspaceProperties.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Projects -{ - /// workspace properties. - public partial class WorkspaceProperties - { - /// - /// 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 . - /// Authentication type of the connection target. - /// is null. - internal WorkspaceProperties(string applicationInsights) - { - Argument.AssertNotNull(applicationInsights, nameof(applicationInsights)); - - ApplicationInsights = applicationInsights; - } - - /// Initializes a new instance of . - /// Authentication type of the connection target. - /// Keeps track of any properties unknown to the library. - internal WorkspaceProperties(string applicationInsights, IDictionary serializedAdditionalRawData) - { - ApplicationInsights = applicationInsights; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal WorkspaceProperties() - { - } - - /// Authentication type of the connection target. - public string ApplicationInsights { get; } - } -} diff --git a/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_ConnectionsClient.cs b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_ConnectionsClient.cs new file mode 100644 index 000000000000..5439fb2c8f7b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_ConnectionsClient.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.Samples +{ + public partial class Samples_ConnectionsClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnections_ConnectionsListMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + ConnectionsClient client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetConnections("AzureOpenAI", true, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("isDefault").ToString()); + Console.WriteLine(result.GetProperty("credentials").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnections_ConnectionsListMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + ConnectionsClient client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetConnectionsAsync("AzureOpenAI", true, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("isDefault").ToString()); + Console.WriteLine(result.GetProperty("credentials").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnections_ConnectionsListMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + ConnectionsClient client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-15-preview"); + + foreach (Connection item in client.GetConnections()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnections_ConnectionsListMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + ConnectionsClient client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-15-preview"); + + await foreach (Connection item in client.GetConnectionsAsync()) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Datasets.cs b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Datasets.cs new file mode 100644 index 000000000000..bdd1c1c3d0e8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Datasets.cs @@ -0,0 +1,835 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.Samples +{ + public partial class Samples_Datasets + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetDataset_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetDataset("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetDataset_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetDatasetAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetDataset_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetDataset("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetDataset_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetDatasetAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetDataset_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetDataset("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetDataset_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetDatasetAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetDataset_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetDataset("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetDataset_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetDatasetAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_Delete_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.Delete("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_Delete_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.DeleteAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_Delete_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.Delete("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_Delete_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.DeleteAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_CreateOrUpdate_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + dataUri = "", + }); + Response response = client.CreateOrUpdate("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_CreateOrUpdate_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + dataUri = "", + }); + Response response = await client.CreateOrUpdateAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_CreateOrUpdate_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + dataUri = "", + connectionName = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = client.CreateOrUpdate("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_CreateOrUpdate_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + dataUri = "", + connectionName = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = await client.CreateOrUpdateAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_PendingUpload_DatasetsStartPendingUploadVersionMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadId = "mxjahcghabuplfwtlopiqgxtcyw", + connectionName = "bknvpmlisrqxaphkf", + pendingUploadType = "BlobReference", + }); + Response response = client.PendingUpload("sgrzyrpltz", "ozdqisviavgqgfbtnzk", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_PendingUpload_DatasetsStartPendingUploadVersionMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadId = "mxjahcghabuplfwtlopiqgxtcyw", + connectionName = "bknvpmlisrqxaphkf", + pendingUploadType = "BlobReference", + }); + Response response = await client.PendingUploadAsync("sgrzyrpltz", "ozdqisviavgqgfbtnzk", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_PendingUpload_DatasetsStartPendingUploadVersionMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + PendingUploadRequest body = new PendingUploadRequest + { + PendingUploadId = "mxjahcghabuplfwtlopiqgxtcyw", + ConnectionName = "bknvpmlisrqxaphkf", + }; + Response response = client.PendingUpload("sgrzyrpltz", "ozdqisviavgqgfbtnzk", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_PendingUpload_DatasetsStartPendingUploadVersionMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + PendingUploadRequest body = new PendingUploadRequest + { + PendingUploadId = "mxjahcghabuplfwtlopiqgxtcyw", + ConnectionName = "bknvpmlisrqxaphkf", + }; + Response response = await client.PendingUploadAsync("sgrzyrpltz", "ozdqisviavgqgfbtnzk", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_PendingUpload_DatasetsStartPendingUploadVersionMinimumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadType = "BlobReference", + }); + Response response = client.PendingUpload("duxoiaywfik", "yzzzt", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_PendingUpload_DatasetsStartPendingUploadVersionMinimumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadType = "BlobReference", + }); + Response response = await client.PendingUploadAsync("duxoiaywfik", "yzzzt", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_PendingUpload_DatasetsStartPendingUploadVersionMinimumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + PendingUploadRequest body = new PendingUploadRequest(); + Response response = client.PendingUpload("duxoiaywfik", "yzzzt", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_PendingUpload_DatasetsStartPendingUploadVersionMinimumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + PendingUploadRequest body = new PendingUploadRequest(); + Response response = await client.PendingUploadAsync("duxoiaywfik", "yzzzt", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetCredentials_DatasetsGetCredentialsMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetCredentials("vzqmzhfdzfqegdk", "cuiflnznlzybcrc", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetCredentials_DatasetsGetCredentialsMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetCredentialsAsync("vzqmzhfdzfqegdk", "cuiflnznlzybcrc", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetCredentials_DatasetsGetCredentialsMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetCredentials("vzqmzhfdzfqegdk", "cuiflnznlzybcrc"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetCredentials_DatasetsGetCredentialsMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetCredentialsAsync("vzqmzhfdzfqegdk", "cuiflnznlzybcrc"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetCredentials_DatasetsGetCredentialsMinimumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetCredentials("sbblxkyqnfvdiqacezyygvts", "ikak", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetCredentials_DatasetsGetCredentialsMinimumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetCredentialsAsync("sbblxkyqnfvdiqacezyygvts", "ikak", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReference").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("sasUri").ToString()); + Console.WriteLine(result.GetProperty("blobReference").GetProperty("credential").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetCredentials_DatasetsGetCredentialsMinimumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetCredentials("sbblxkyqnfvdiqacezyygvts", "ikak"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetCredentials_DatasetsGetCredentialsMinimumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetCredentialsAsync("sbblxkyqnfvdiqacezyygvts", "ikak"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersions_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetVersions("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersions_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetVersionsAsync("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersions_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + foreach (DatasetVersion item in client.GetVersions("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersions_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + await foreach (DatasetVersion item in client.GetVersionsAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersions_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetVersions("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersions_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetVersionsAsync("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersions_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + foreach (DatasetVersion item in client.GetVersions("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersions_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + await foreach (DatasetVersion item in client.GetVersionsAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DatasetVersion_GetDatasetVersions_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetDatasetVersions(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DatasetVersion_GetDatasetVersions_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetDatasetVersionsAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DatasetVersion_GetDatasetVersions_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + foreach (DatasetVersion item in client.GetDatasetVersions()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DatasetVersion_GetDatasetVersions_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + await foreach (DatasetVersion item in client.GetDatasetVersionsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DatasetVersion_GetDatasetVersions_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetDatasetVersions(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DatasetVersion_GetDatasetVersions_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetDatasetVersionsAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("dataUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("connectionName").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DatasetVersion_GetDatasetVersions_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + foreach (DatasetVersion item in client.GetDatasetVersions()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DatasetVersion_GetDatasetVersions_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-15-preview"); + + await foreach (DatasetVersion item in client.GetDatasetVersionsAsync()) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Deployments.cs b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Deployments.cs new file mode 100644 index 000000000000..76a58963e36b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Deployments.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.Samples +{ + public partial class Samples_Deployments + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployment_DeploymentsGetMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetDeployment("qqvacpzjfk", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployment_DeploymentsGetMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetDeploymentAsync("qqvacpzjfk", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployment_DeploymentsGetMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetDeployment("qqvacpzjfk"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployment_DeploymentsGetMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetDeploymentAsync("qqvacpzjfk"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployments_DeploymentsListMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetDeployments("kznreojrvlwdq", "gplerszsuyisseeksnyvkaqperxox", null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployments_DeploymentsListMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetDeploymentsAsync("kznreojrvlwdq", "gplerszsuyisseeksnyvkaqperxox", null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployments_DeploymentsListMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + + foreach (Deployment item in client.GetDeployments()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployments_DeploymentsListMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-15-preview"); + + await foreach (Deployment item in client.GetDeploymentsAsync()) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_EvaluationsClient.cs b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_EvaluationsClient.cs new file mode 100644 index 000000000000..33d1952a87b2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_EvaluationsClient.cs @@ -0,0 +1,560 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.Samples +{ + public partial class Samples_EvaluationsClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluation_EvaluationsGetMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetEvaluation("so", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluation_EvaluationsGetMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetEvaluationAsync("so", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluation_EvaluationsGetMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetEvaluation("so"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluation_EvaluationsGetMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetEvaluationAsync("so"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_Create_EvaluationsCreateMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + displayName = "ymjxkodggqrhjnmusta", + description = "cuviaxytqckkybxwc", + tags = new + { + key30 = "nqrdpedyhkjzgrbtqhxbmkdmlpdf", + }, + properties = new + { + key9192 = "e", + }, + evaluators = new + { + key2735 = new + { + id = "gujwtvhptykq", + initParams = new object(), + dataMapping = new + { + key7400 = "ijkjfvoswni", + }, + }, + }, + }); + Response response = client.Create(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_Create_EvaluationsCreateMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + displayName = "ymjxkodggqrhjnmusta", + description = "cuviaxytqckkybxwc", + tags = new + { + key30 = "nqrdpedyhkjzgrbtqhxbmkdmlpdf", + }, + properties = new + { + key9192 = "e", + }, + evaluators = new + { + key2735 = new + { + id = "gujwtvhptykq", + initParams = new object(), + dataMapping = new + { + key7400 = "ijkjfvoswni", + }, + }, + }, + }); + Response response = await client.CreateAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_Create_EvaluationsCreateMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + Evaluation evaluation = new Evaluation(null, new Dictionary + { + ["key2735"] = new EvaluatorConfiguration("gujwtvhptykq") + { + InitParams = { }, + DataMapping = +{ +["key7400"] = "ijkjfvoswni" +}, + } + }) + { + DisplayName = "ymjxkodggqrhjnmusta", + Description = "cuviaxytqckkybxwc", + Tags = +{ +["key30"] = "nqrdpedyhkjzgrbtqhxbmkdmlpdf" +}, + Properties = +{ +["key9192"] = "e" +}, + }; + Response response = client.Create(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_Create_EvaluationsCreateMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + Evaluation evaluation = new Evaluation(null, new Dictionary + { + ["key2735"] = new EvaluatorConfiguration("gujwtvhptykq") + { + InitParams = { }, + DataMapping = +{ +["key7400"] = "ijkjfvoswni" +}, + } + }) + { + DisplayName = "ymjxkodggqrhjnmusta", + Description = "cuviaxytqckkybxwc", + Tags = +{ +["key30"] = "nqrdpedyhkjzgrbtqhxbmkdmlpdf" +}, + Properties = +{ +["key9192"] = "e" +}, + }; + Response response = await client.CreateAsync(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_Create_EvaluationsCreateMinimumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + evaluators = new object(), + }); + Response response = client.Create(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_Create_EvaluationsCreateMinimumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + evaluators = new object(), + }); + Response response = await client.CreateAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_Create_EvaluationsCreateMinimumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + Evaluation evaluation = new Evaluation(null, new Dictionary()); + Response response = client.Create(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_Create_EvaluationsCreateMinimumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + Evaluation evaluation = new Evaluation(null, new Dictionary()); + Response response = await client.CreateAsync(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_CreateAgentEvaluation_EvaluationsCreateAgentEvaluationMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + runId = "ecfcffqsrdhpecocrufffiqz", + threadId = "cxjjsyhkeezgnaqqyerrdrbbth", + evaluators = new + { + key2653 = new + { + id = "gujwtvhptykq", + initParams = new object(), + dataMapping = new + { + key7400 = "ijkjfvoswni", + }, + }, + }, + samplingConfiguration = new + { + name = "tj", + samplingPercent = 7F, + maxRequestRate = 8F, + }, + redactionConfiguration = new + { + redactScoreProperties = true, + }, + appInsightsConnectionString = "dvcnrcwar", + }); + Response response = client.CreateAgentEvaluation(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_CreateAgentEvaluation_EvaluationsCreateAgentEvaluationMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + runId = "ecfcffqsrdhpecocrufffiqz", + threadId = "cxjjsyhkeezgnaqqyerrdrbbth", + evaluators = new + { + key2653 = new + { + id = "gujwtvhptykq", + initParams = new object(), + dataMapping = new + { + key7400 = "ijkjfvoswni", + }, + }, + }, + samplingConfiguration = new + { + name = "tj", + samplingPercent = 7F, + maxRequestRate = 8F, + }, + redactionConfiguration = new + { + redactScoreProperties = true, + }, + appInsightsConnectionString = "dvcnrcwar", + }); + Response response = await client.CreateAgentEvaluationAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_CreateAgentEvaluation_EvaluationsCreateAgentEvaluationMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + AgentEvaluationRequest evaluation = new AgentEvaluationRequest("ecfcffqsrdhpecocrufffiqz", new Dictionary + { + ["key2653"] = new EvaluatorConfiguration("gujwtvhptykq") + { + InitParams = { }, + DataMapping = +{ +["key7400"] = "ijkjfvoswni" +}, + } + }, "dvcnrcwar") + { + ThreadId = "cxjjsyhkeezgnaqqyerrdrbbth", + SamplingConfiguration = new AgentEvaluationSamplingConfiguration("tj", 7F, 8F), + RedactionConfiguration = new AgentEvaluationRedactionConfiguration + { + RedactScoreProperties = true, + }, + }; + Response response = client.CreateAgentEvaluation(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_CreateAgentEvaluation_EvaluationsCreateAgentEvaluationMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + AgentEvaluationRequest evaluation = new AgentEvaluationRequest("ecfcffqsrdhpecocrufffiqz", new Dictionary + { + ["key2653"] = new EvaluatorConfiguration("gujwtvhptykq") + { + InitParams = { }, + DataMapping = +{ +["key7400"] = "ijkjfvoswni" +}, + } + }, "dvcnrcwar") + { + ThreadId = "cxjjsyhkeezgnaqqyerrdrbbth", + SamplingConfiguration = new AgentEvaluationSamplingConfiguration("tj", 7F, 8F), + RedactionConfiguration = new AgentEvaluationRedactionConfiguration + { + RedactScoreProperties = true, + }, + }; + Response response = await client.CreateAgentEvaluationAsync(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_CreateAgentEvaluation_EvaluationsCreateAgentEvaluationMinimumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + runId = "ecfcffqsrdhpecocrufffiqz", + evaluators = new object(), + appInsightsConnectionString = "dvcnrcwar", + }); + Response response = client.CreateAgentEvaluation(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_CreateAgentEvaluation_EvaluationsCreateAgentEvaluationMinimumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + runId = "ecfcffqsrdhpecocrufffiqz", + evaluators = new object(), + appInsightsConnectionString = "dvcnrcwar", + }); + Response response = await client.CreateAgentEvaluationAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_CreateAgentEvaluation_EvaluationsCreateAgentEvaluationMinimumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + AgentEvaluationRequest evaluation = new AgentEvaluationRequest("ecfcffqsrdhpecocrufffiqz", new Dictionary(), "dvcnrcwar"); + Response response = client.CreateAgentEvaluation(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_CreateAgentEvaluation_EvaluationsCreateAgentEvaluationMinimumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + AgentEvaluationRequest evaluation = new AgentEvaluationRequest("ecfcffqsrdhpecocrufffiqz", new Dictionary(), "dvcnrcwar"); + Response response = await client.CreateAgentEvaluationAsync(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluations_EvaluationsListMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetEvaluations(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluations_EvaluationsListMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetEvaluationsAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluations_EvaluationsListMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + foreach (Evaluation item in client.GetEvaluations()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluations_EvaluationsListMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + EvaluationsClient client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-15-preview"); + + await foreach (Evaluation item in client.GetEvaluationsAsync()) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Indexes.cs b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Indexes.cs new file mode 100644 index 000000000000..52d4e8245952 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_Indexes.cs @@ -0,0 +1,577 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.Samples +{ + public partial class Samples_Indexes + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetIndex_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetIndex("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetIndex_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetIndexAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetIndex_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetIndex("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetIndex_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetIndexAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetIndex_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetIndex("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetIndex_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetIndexAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetIndex_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetIndex("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetIndex_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetIndexAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_Delete_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = client.Delete("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_Delete_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.DeleteAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_Delete_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = client.Delete("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_Delete_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.DeleteAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_CreateOrUpdate_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + }); + Response response = client.CreateOrUpdate("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_CreateOrUpdate_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + }); + Response response = await client.CreateOrUpdateAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_CreateOrUpdate_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + fieldMapping = new + { + contentFields = new object[] + { +"" + }, + filepathField = "", + titleField = "", + urlField = "", + vectorFields = new object[] + { +"" + }, + metadataFields = new object[] + { +"" + }, + }, + description = "", + tags = new + { + key = "", + }, + }); + Response response = client.CreateOrUpdate("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_CreateOrUpdate_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + fieldMapping = new + { + contentFields = new object[] + { +"" + }, + filepathField = "", + titleField = "", + urlField = "", + vectorFields = new object[] + { +"" + }, + metadataFields = new object[] + { +"" + }, + }, + description = "", + tags = new + { + key = "", + }, + }); + Response response = await client.CreateOrUpdateAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersions_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetVersions("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersions_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetVersionsAsync("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersions_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + foreach (Index item in client.GetVersions("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersions_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + await foreach (Index item in client.GetVersionsAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersions_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetVersions("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersions_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetVersionsAsync("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersions_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + foreach (Index item in client.GetVersions("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersions_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + await foreach (Index item in client.GetVersionsAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Index_GetIndices_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetIndices(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Index_GetIndices_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetIndicesAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Index_GetIndices_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + foreach (Index item in client.GetIndices()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Index_GetIndices_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + await foreach (Index item in client.GetIndicesAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Index_GetIndices_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetIndices(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Index_GetIndices_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetIndicesAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Index_GetIndices_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + foreach (Index item in client.GetIndices()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Index_GetIndices_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-15-preview"); + + await foreach (Index item in client.GetIndicesAsync()) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_RedTeams.cs b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_RedTeams.cs new file mode 100644 index 000000000000..1652693539c8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Generated/Samples/Samples_RedTeams.cs @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.Samples +{ + public partial class Samples_RedTeams + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RedTeam_GetRedTeam_RedTeamsGetMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetRedTeam("apwpcf", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RedTeam_GetRedTeam_RedTeamsGetMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetRedTeamAsync("apwpcf", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RedTeam_GetRedTeam_RedTeamsGetMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + Response response = client.GetRedTeam("apwpcf"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RedTeam_GetRedTeam_RedTeamsGetMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + Response response = await client.GetRedTeamAsync("apwpcf"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RedTeams_Create_RedTeamsCreateMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + numTurns = 10, + attackStrategies = new object[] + { +"easy" + }, + simulationOnly = true, + riskCategories = new object[] + { +"HateUnfairness" + }, + applicationScenario = "qaxxxhjp", + tags = new + { + key1287 = "gbklekkgmxkfbhehgh", + }, + properties = new + { + key9280 = "fwzjtipl", + }, + }); + Response response = client.Create(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RedTeams_Create_RedTeamsCreateMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + numTurns = 10, + attackStrategies = new object[] + { +"easy" + }, + simulationOnly = true, + riskCategories = new object[] + { +"HateUnfairness" + }, + applicationScenario = "qaxxxhjp", + tags = new + { + key1287 = "gbklekkgmxkfbhehgh", + }, + properties = new + { + key9280 = "fwzjtipl", + }, + }); + Response response = await client.CreateAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RedTeams_Create_RedTeamsCreateMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + RedTeam redTeam = new RedTeam(null) + { + NumTurns = 10, + AttackStrategies = { AttackStrategy.Easy }, + SimulationOnly = true, + RiskCategories = { RiskCategory.HateUnfairness }, + ApplicationScenario = "qaxxxhjp", + Tags = +{ +["key1287"] = "gbklekkgmxkfbhehgh" +}, + Properties = +{ +["key9280"] = "fwzjtipl" +}, + }; + Response response = client.Create(redTeam); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RedTeams_Create_RedTeamsCreateMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + RedTeam redTeam = new RedTeam(null) + { + NumTurns = 10, + AttackStrategies = { AttackStrategy.Easy }, + SimulationOnly = true, + RiskCategories = { RiskCategory.HateUnfairness }, + ApplicationScenario = "qaxxxhjp", + Tags = +{ +["key1287"] = "gbklekkgmxkfbhehgh" +}, + Properties = +{ +["key9280"] = "fwzjtipl" +}, + }; + Response response = await client.CreateAsync(redTeam); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RedTeams_Create_RedTeamsCreateMinimumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + numTurns = 10, + attackStrategies = new object[] + { +"easy" + }, + simulationOnly = true, + riskCategories = new object[] + { +"HateUnfairness" + }, + }); + Response response = client.Create(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RedTeams_Create_RedTeamsCreateMinimumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + using RequestContent content = RequestContent.Create(new + { + numTurns = 10, + attackStrategies = new object[] + { +"easy" + }, + simulationOnly = true, + riskCategories = new object[] + { +"HateUnfairness" + }, + }); + Response response = await client.CreateAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RedTeams_Create_RedTeamsCreateMinimumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + RedTeam redTeam = new RedTeam(null) + { + NumTurns = 10, + AttackStrategies = { AttackStrategy.Easy }, + SimulationOnly = true, + RiskCategories = { RiskCategory.HateUnfairness }, + }; + Response response = client.Create(redTeam); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RedTeams_Create_RedTeamsCreateMinimumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + RedTeam redTeam = new RedTeam(null) + { + NumTurns = 10, + AttackStrategies = { AttackStrategy.Easy }, + SimulationOnly = true, + RiskCategories = { RiskCategory.HateUnfairness }, + }; + Response response = await client.CreateAsync(redTeam); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RedTeam_GetRedTeams_RedTeamsListMaximumSet() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + foreach (BinaryData item in client.GetRedTeams(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RedTeam_GetRedTeams_RedTeamsListMaximumSet_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + await foreach (BinaryData item in client.GetRedTeamsAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("target").GetProperty("type").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RedTeam_GetRedTeams_RedTeamsListMaximumSet_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + foreach (RedTeam item in client.GetRedTeams()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RedTeam_GetRedTeams_RedTeamsListMaximumSet_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview"); + + await foreach (RedTeam item in client.GetRedTeamsAsync()) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/tsp-location.yaml b/sdk/ai/Azure.AI.Projects/tsp-location.yaml index 7aa8fb854ef9..45516c5a5198 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: 0c16eaab2ab3fb6379871f77353251bd6f5c643a +commit: ad1519430bfa3eda97edb8a2e9cabffc51f5fbca repo: Azure/azure-rest-api-specs additionalDirectories: