diff --git a/sdk/ai/Azure.AI.Projects/Azure.AI.Projects.sln b/sdk/ai/Azure.AI.Projects/Azure.AI.Projects.sln
new file mode 100644
index 000000000000..81113161b082
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/Azure.AI.Projects.sln
@@ -0,0 +1,56 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29709.97
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects", "src\Azure.AI.Projects.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects.Tests", "tests\Azure.AI.Projects.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE}
+ EndGlobalSection
+EndGlobal
diff --git a/sdk/ai/Azure.AI.Projects/CHANGELOG.md b/sdk/ai/Azure.AI.Projects/CHANGELOG.md
new file mode 100644
index 000000000000..13dd08af78ab
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/CHANGELOG.md
@@ -0,0 +1,11 @@
+# Release History
+
+## 1.0.0-beta.1 (Unreleased)
+
+### Features Added
+
+### Breaking Changes
+
+### Bugs Fixed
+
+### Other Changes
diff --git a/sdk/ai/Azure.AI.Projects/Directory.Build.props b/sdk/ai/Azure.AI.Projects/Directory.Build.props
new file mode 100644
index 000000000000..63bd836ad44b
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/Directory.Build.props
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/sdk/ai/Azure.AI.Projects/README.md b/sdk/ai/Azure.AI.Projects/README.md
new file mode 100644
index 000000000000..249fee0eaac8
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/README.md
@@ -0,0 +1,107 @@
+# Azure.AI.Projects client library for .NET
+
+Azure.AI.Projects is a managed service that helps developers get secret simply and securely.
+
+Use the client library for to:
+
+* [Get secret](https://docs.microsoft.com/azure)
+
+[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples]
+
+ [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Projects/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure)
+
+## Getting started
+
+This section should include everything a developer needs to do to install and create their first client connection *very quickly*.
+
+### Install the package
+
+First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository.
+
+Install the client library for .NET with [NuGet](https://www.nuget.org/ ):
+
+```dotnetcli
+dotnet add package Azure.AI.Projects --prerelease
+```
+
+### Prerequisites
+
+Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB:
+
+> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`.
+
+### Authenticate the client
+
+If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating.
+
+For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object.
+
+### Service API versions
+
+The client library targets the latest service API version by default. A client instance accepts an optional service API version parameter from its options to specify which API version service to communicate.
+
+#### Select a service API version
+
+You have the flexibility to explicitly select a supported service API version when instantiating a client by configuring its associated options. This ensures that the client can communicate with services using the specified API version.
+
+For example,
+
+```C# Snippet:CreateClientForSpecificApiVersion
+Uri endpoint = new Uri("");
+DefaultAzureCredential credential = new DefaultAzureCredential();
+ClientOptions options = new ClientOptions(ClientOptions.ServiceVersion.)
+var client = new Client(endpoint, credential, options);
+```
+
+When selecting an API version, it's important to verify that there are no breaking changes compared to the latest API version. If there are significant differences, API calls may fail due to incompatibility.
+
+Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy.
+
+## Key concepts
+
+The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity.
+
+Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of:
+
+### Thread safety
+
+We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads.
+
+### Additional concepts
+
+[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) |
+[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) |
+[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) |
+[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) |
+[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) |
+[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) |
+[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/)
+
+
+## Examples
+
+You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Projects/samples).
+
+## Troubleshooting
+
+Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery.
+
+Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API.
+
+If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code.
+
+## Next steps
+
+* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory.
+* If appropriate, point users to other packages that might be useful.
+* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for.
+
+## Contributing
+
+This is a template, but your SDK readme should include details on how to contribute code to the repo/package.
+
+
+[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization
+[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide
+
+
diff --git a/sdk/ai/Azure.AI.Projects/src/Azure.AI.Projects.csproj b/sdk/ai/Azure.AI.Projects/src/Azure.AI.Projects.csproj
new file mode 100644
index 000000000000..fb559851efc3
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Azure.AI.Projects.csproj
@@ -0,0 +1,19 @@
+
+
+ This is the Azure.AI.Projects client library for developing .NET applications with rich experience.
+ Azure SDK Code Generation Azure.AI.Projects for Azure Data Plane
+ 1.0.0-beta.1
+ Azure.AI.Projects
+ $(RequiredTargetFrameworks)
+ true
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs
new file mode 100644
index 000000000000..749492935d7d
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs
@@ -0,0 +1,116 @@
+// 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 client.
+ /// The AIProject service client.
+ public partial class AIProjectClient
+ {
+ 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;
+
+ /// 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 AIProjectClient for mocking.
+ protected AIProjectClient()
+ {
+ }
+
+ /// Initializes a new instance of AIProjectClient.
+ /// The Azure AI Studio 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 Studio 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())
+ {
+ }
+
+ /// Initializes a new instance of AIProjectClient.
+ /// The Azure AI Studio 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 Studio project name.
+ /// A credential used to authenticate to an Azure Service.
+ /// The options for configuring the client.
+ /// , , , 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, AIProjectClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(projectName, nameof(projectName));
+ 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;
+ _subscriptionId = subscriptionId;
+ _resourceGroupName = resourceGroupName;
+ _projectName = projectName;
+ }
+
+ /// Initializes a new instance of Agents.
+ /// The API version to use for this operation.
+ /// is null.
+ public virtual Agents GetAgentsClient(string apiVersion = "2024-07-01-preview")
+ {
+ Argument.AssertNotNull(apiVersion, nameof(apiVersion));
+
+ return new Agents(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _subscriptionId, _resourceGroupName, _projectName, apiVersion);
+ }
+
+ /// Initializes a new instance of Connections.
+ /// The API version to use for this operation.
+ /// is null.
+ public virtual Connections GetConnectionsClient(string apiVersion = "2024-07-01-preview")
+ {
+ Argument.AssertNotNull(apiVersion, nameof(apiVersion));
+
+ return new Connections(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _subscriptionId, _resourceGroupName, _projectName, apiVersion);
+ }
+
+ /// Initializes a new instance of Telemetry.
+ /// The API version to use for this operation.
+ /// is null.
+ public virtual Telemetry GetTelemetryClient(string apiVersion = "2024-07-01-preview")
+ {
+ Argument.AssertNotNull(apiVersion, nameof(apiVersion));
+
+ return new Telemetry(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _subscriptionId, _resourceGroupName, _projectName, apiVersion);
+ }
+
+ /// Initializes a new instance of Evaluations.
+ /// The API version to use for this operation.
+ /// is null.
+ public virtual Evaluations GetEvaluationsClient(string apiVersion = "2024-07-01-preview")
+ {
+ Argument.AssertNotNull(apiVersion, nameof(apiVersion));
+
+ return new Evaluations(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, _subscriptionId, _resourceGroupName, _projectName, apiVersion);
+ }
+ }
+}
diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs
new file mode 100644
index 000000000000..ee91a3c1030c
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs
@@ -0,0 +1,37 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.AI.Projects
+{
+ /// Client options for AIProjectClient.
+ public partial class AIProjectClientOptions : ClientOptions
+ {
+ private const ServiceVersion LatestVersion = ServiceVersion.V2024_07_01_Preview;
+
+ /// The version of the service to use.
+ public enum ServiceVersion
+ {
+ /// Service version "2024-07-01-preview".
+ V2024_07_01_Preview = 1,
+ }
+
+ internal string Version { get; }
+
+ /// Initializes new instance of AIProjectClientOptions.
+ public AIProjectClientOptions(ServiceVersion version = LatestVersion)
+ {
+ Version = version switch
+ {
+ ServiceVersion.V2024_07_01_Preview => "2024-07-01-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
new file mode 100644
index 000000000000..02f3bc489b92
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsClientBuilderExtensions.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.AI.Projects;
+using Azure.Core.Extensions;
+
+namespace Microsoft.Extensions.Azure
+{
+ /// Extension methods to add to client builder.
+ public static partial class AIProjectsClientBuilderExtensions
+ {
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The Azure AI Studio 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 Studio project name.
+ public static IAzureClientBuilder AddAIProjectClient(this TBuilder builder, Uri endpoint, string subscriptionId, string resourceGroupName, string projectName)
+ where TBuilder : IAzureClientFactoryBuilderWithCredential
+ {
+ return builder.RegisterClientFactory((options, cred) => new AIProjectClient(endpoint, subscriptionId, resourceGroupName, projectName, cred, options));
+ }
+
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The configuration values.
+ public static IAzureClientBuilder AddAIProjectClient(this TBuilder builder, TConfiguration configuration)
+ where TBuilder : IAzureClientFactoryBuilderWithConfiguration
+ {
+ return builder.RegisterClientFactory(configuration);
+ }
+ }
+}
diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs
new file mode 100644
index 000000000000..d732dbbe8ea7
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs
@@ -0,0 +1,1008 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+namespace Azure.AI.Projects
+{
+ /// Model factory for models.
+ public static partial class AIProjectsModelFactory
+ {
+ /// Initializes a new instance of .
+ /// 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 .
+ ///
+ /// Display Name for evaluation. It helps to find evaluation easily in AI Studio. 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, string displayName = null, string description = null, SystemData systemData = 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,
+ data,
+ displayName,
+ description,
+ systemData,
+ status,
+ tags,
+ properties,
+ evaluators,
+ 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.
+ /// 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.
+ ///
+ /// 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 provisioningStatus = null, IDictionary tags = null, IDictionary properties = null, IDictionary evaluators = null, Trigger trigger = null)
+ {
+ tags ??= new Dictionary();
+ properties ??= new Dictionary();
+ evaluators ??= new Dictionary();
+
+ return new EvaluationSchedule(
+ name,
+ data,
+ description,
+ systemData,
+ provisioningStatus,
+ tags,
+ properties,
+ evaluators,
+ trigger,
+ serializedAdditionalRawData: null);
+ }
+
+ /// 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.
+ /// A new instance for mocking.
+ public static Agent Agent(string id = null, AgentObject @object = default, DateTimeOffset createdAt = default, string name = null, string description = null, string model = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null)
+ {
+ tools ??= new List();
+ metadata ??= new Dictionary();
+
+ return new Agent(
+ id,
+ @object,
+ createdAt,
+ name,
+ description,
+ model,
+ instructions,
+ tools?.ToList(),
+ toolResources,
+ temperature,
+ topP,
+ responseFormat,
+ metadata,
+ serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ ///
+ /// The role of the entity that is creating the message. Allowed values include:
+ /// - `user`: Indicates the message is sent by an actual user and should be used in most
+ /// cases to represent user-generated messages.
+ /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert
+ /// messages from the agent into the
+ /// conversation.
+ ///
+ ///
+ /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via
+ /// a separate call to the create message API.
+ ///
+ /// 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, string content = null, IEnumerable attachments = null, IDictionary metadata = null)
+ {
+ attachments ??= new List();
+ metadata ??= new Dictionary();
+
+ return new ThreadMessageOptions(role, content, attachments?.ToList(), metadata, serializedAdditionalRawData: null);
+ }
+
+ /// 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.
+ /// A new instance for mocking.
+ public static AgentThread AgentThread(string id = null, AgentThreadObject @object = default, DateTimeOffset createdAt = default, ToolResources toolResources = null, IReadOnlyDictionary metadata = null)
+ {
+ metadata ??= new Dictionary();
+
+ return new AgentThread(
+ id,
+ @object,
+ createdAt,
+ toolResources,
+ metadata,
+ serializedAdditionalRawData: null);
+ }
+
+ /// 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.
+ /// A new instance for mocking.
+ public static ThreadMessage ThreadMessage(string id = null, ThreadMessageObject @object = default, DateTimeOffset createdAt = default, string threadId = null, MessageStatus status = default, MessageIncompleteDetails incompleteDetails = null, DateTimeOffset? completedAt = null, DateTimeOffset? incompleteAt = null, MessageRole role = default, IEnumerable contentItems = null, string assistantId = null, string runId = null, IEnumerable attachments = null, IDictionary metadata = null)
+ {
+ contentItems ??= new List();
+ attachments ??= new List();
+ metadata ??= new Dictionary();
+
+ return new ThreadMessage(
+ id,
+ @object,
+ createdAt,
+ threadId,
+ status,
+ incompleteDetails,
+ completedAt,
+ incompleteAt,
+ role,
+ contentItems?.ToList(),
+ assistantId,
+ runId,
+ attachments?.ToList(),
+ metadata,
+ serializedAdditionalRawData: null);
+ }
+
+ /// 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.
+ /// A new instance for mocking.
+ public static ThreadRun ThreadRun(string id = null, ThreadRunObject @object = default, string threadId = null, string assistantId = null, RunStatus status = default, RequiredAction requiredAction = null, RunError lastError = null, string model = null, string instructions = null, IEnumerable tools = null, DateTimeOffset createdAt = default, DateTimeOffset? expiresAt = null, DateTimeOffset? startedAt = null, DateTimeOffset? completedAt = null, DateTimeOffset? cancelledAt = null, DateTimeOffset? failedAt = null, IncompleteRunDetails? incompleteDetails = null, RunCompletionUsage usage = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, UpdateToolResourcesOptions toolResources = null, bool? parallelToolCalls = null)
+ {
+ tools ??= new List();
+ metadata ??= new Dictionary();
+
+ return new ThreadRun(
+ id,
+ @object,
+ threadId,
+ assistantId,
+ status,
+ requiredAction,
+ lastError,
+ model,
+ instructions,
+ tools?.ToList(),
+ createdAt,
+ expiresAt,
+ startedAt,
+ completedAt,
+ cancelledAt,
+ failedAt,
+ incompleteDetails,
+ usage,
+ temperature,
+ topP,
+ maxPromptTokens,
+ maxCompletionTokens,
+ truncationStrategy,
+ toolChoice,
+ responseFormat,
+ metadata,
+ toolResources,
+ parallelToolCalls,
+ serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// The object type for the required tool call.
+ /// 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, id, serializedAdditionalRawData: null);
+ }
+
+ /// 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 .
+ /// 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 .
+ /// 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.
+ /// A new instance for mocking.
+ public static RunStep RunStep(string id = null, RunStepObject @object = default, RunStepType type = default, string assistantId = null, string threadId = null, string runId = null, RunStepStatus status = default, RunStepDetails stepDetails = null, RunStepError lastError = null, DateTimeOffset createdAt = default, DateTimeOffset? expiredAt = null, DateTimeOffset? completedAt = null, DateTimeOffset? cancelledAt = null, DateTimeOffset? failedAt = null, RunStepCompletionUsage usage = null, IReadOnlyDictionary metadata = null)
+ {
+ metadata ??= new Dictionary();
+
+ return new RunStep(
+ id,
+ @object,
+ type,
+ assistantId,
+ threadId,
+ runId,
+ status,
+ stepDetails,
+ lastError,
+ createdAt,
+ expiredAt,
+ completedAt,
+ cancelledAt,
+ failedAt,
+ usage,
+ metadata,
+ 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 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 RunStepFileSearchToolCall RunStepFileSearchToolCall(string id = null, IReadOnlyDictionary fileSearch = null)
+ {
+ fileSearch ??= new Dictionary();
+
+ return new RunStepFileSearchToolCall("file_search", id, serializedAdditionalRawData: null, fileSearch);
+ }
+
+ /// 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("microsoft_fabric", id, serializedAdditionalRawData: null, microsoftFabric);
+ }
+
+ /// 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 '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.
+ /// A new instance for mocking.
+ public static OpenAIFile OpenAIFile(OpenAIFileObject @object = default, string id = null, int size = default, string filename = null, DateTimeOffset createdAt = default, OpenAIFilePurpose purpose = default, FileState? status = null, string statusDetails = null)
+ {
+ return new OpenAIFile(
+ @object,
+ id,
+ size,
+ filename,
+ createdAt,
+ purpose,
+ status,
+ statusDetails,
+ 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 OpenAIPageableListOfVectorStore OpenAIPageableListOfVectorStore(OpenAIPageableListOfVectorStoreObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default)
+ {
+ data ??= new List();
+
+ return new OpenAIPageableListOfVectorStore(
+ @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,
+ 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 OpenAIPageableListOfVectorStoreFile OpenAIPageableListOfVectorStoreFile(OpenAIPageableListOfVectorStoreFileObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default)
+ {
+ data ??= new List();
+
+ return new OpenAIPageableListOfVectorStoreFile(
+ @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,
+ 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)
+ {
+ content ??= new List();
+
+ return new MessageDelta(role, content?.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)
+ {
+ return new UnknownMessageDeltaContent(index, type, serializedAdditionalRawData: null);
+ }
+
+ /// 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);
+ }
+
+ /// 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)
+ {
+ return new MessageDeltaImageFileContentObject(fileId, serializedAdditionalRawData: null);
+ }
+
+ /// 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);
+ }
+
+ /// 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)
+ {
+ annotations ??= new List();
+
+ return new MessageDeltaTextContentObject(value, annotations?.ToList(), 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)
+ {
+ return new UnknownMessageDeltaTextAnnotation(index, type, 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)
+ {
+ return new MessageDeltaTextFileCitationAnnotation(
+ index,
+ "file_citation",
+ serializedAdditionalRawData: null,
+ fileCitation,
+ text,
+ startIndex,
+ endIndex);
+ }
+
+ /// 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)
+ {
+ return new MessageDeltaTextFileCitationAnnotationObject(fileId, quote, 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)
+ {
+ return new MessageDeltaTextFilePathAnnotation(
+ index,
+ "file_path",
+ serializedAdditionalRawData: null,
+ filePath,
+ startIndex,
+ endIndex,
+ text);
+ }
+
+ /// Initializes a new instance of .
+ /// The file ID for the annotation.
+ /// A new instance for mocking.
+ public static MessageDeltaTextFilePathAnnotationObject MessageDeltaTextFilePathAnnotationObject(string fileId = null)
+ {
+ return new MessageDeltaTextFilePathAnnotationObject(fileId, 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)
+ {
+ return new RunStepDeltaChunk(id, @object, delta, serializedAdditionalRawData: null);
+ }
+
+ /// 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);
+ }
+
+ /// Initializes a new instance of .
+ /// The message creation data.
+ /// A new instance for mocking.
+ public static RunStepDeltaMessageCreation RunStepDeltaMessageCreation(RunStepDeltaMessageCreationObject messageCreation = null)
+ {
+ return new RunStepDeltaMessageCreation("message_creation", serializedAdditionalRawData: null, messageCreation);
+ }
+
+ /// 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);
+ }
+
+ /// 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)
+ {
+ toolCalls ??= new List();
+
+ return new RunStepDeltaToolCallObject("tool_calls", serializedAdditionalRawData: null, toolCalls?.ToList());
+ }
+
+ /// 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)
+ {
+ return new UnknownRunStepDeltaToolCall(index, id, type, 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.
+ /// 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);
+ }
+
+ /// 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)
+ {
+ return new RunStepDeltaFunction(name, arguments, output, 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, IReadOnlyDictionary fileSearch = null)
+ {
+ fileSearch ??= new Dictionary();
+
+ return new RunStepDeltaFileSearchToolCall(index, id, "file_search", serializedAdditionalRawData: null, fileSearch);
+ }
+
+ /// 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);
+ }
+
+ /// 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 .
+ ///
+ /// 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)
+ {
+ 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);
+ }
+
+ /// 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);
+ }
+ }
+}
diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Agent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Agent.Serialization.cs
new file mode 100644
index 000000000000..3de201a497f1
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/Agent.Serialization.cs
@@ -0,0 +1,372 @@
+// 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)
+ {
+ 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.WriteStartObject();
+ writer.WritePropertyName("id"u8);
+ writer.WriteStringValue(Id);
+ writer.WritePropertyName("object"u8);
+ writer.WriteStringValue(Object.ToString());
+ 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))
+ {
+ 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))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ writer.WriteEndObject();
+ }
+
+ 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;
+ AgentObject @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 = new AgentObject(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);
+ 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);
+ 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);
+ 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
new file mode 100644
index 000000000000..db4c100adddc
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/Agent.cs
@@ -0,0 +1,235 @@
+// 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, AgentObject @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 object type, which is always assistant.
+ public AgentObject Object { get; } = AgentObject.Assistant;
+
+ /// 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/AgentObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentObject.cs
new file mode 100644
index 000000000000..2d1b354dbe48
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentObject.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 Agent_object.
+ public readonly partial struct AgentObject : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public AgentObject(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string AssistantValue = "assistant";
+
+ /// assistant.
+ public static AgentObject Assistant { get; } = new AgentObject(AssistantValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(AgentObject left, AgentObject right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(AgentObject left, AgentObject right) => !left.Equals(right);
+ /// Converts a to a .
+ public static implicit operator AgentObject(string value) => new AgentObject(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is AgentObject other && Equals(other);
+ ///
+ public bool Equals(AgentObject 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
new file mode 100644
index 000000000000..467c36acfd8b
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentStreamEvent.cs
@@ -0,0 +1,134 @@
+// 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 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 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.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.Serialization.cs
new file mode 100644
index 000000000000..ccef9b484691
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.Serialization.cs
@@ -0,0 +1,208 @@
+// 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 AgentThread : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ 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.");
+ }
+
+ writer.WriteStartObject();
+ writer.WritePropertyName("id"u8);
+ writer.WriteStringValue(Id);
+ writer.WritePropertyName("object"u8);
+ writer.WriteStringValue(Object.ToString());
+ writer.WritePropertyName("created_at"u8);
+ writer.WriteNumberValue(CreatedAt, "U");
+ if (ToolResources != null)
+ {
+ writer.WritePropertyName("tool_resources"u8);
+ writer.WriteObjectValue(ToolResources, options);
+ }
+ else
+ {
+ writer.WriteNull("tool_resources");
+ }
+ 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))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ writer.WriteEndObject();
+ }
+
+ AgentThread 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(AgentThread)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAgentThread(document.RootElement, options);
+ }
+
+ internal static AgentThread DeserializeAgentThread(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string id = default;
+ AgentThreadObject @object = default;
+ DateTimeOffset createdAt = default;
+ ToolResources toolResources = 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 AgentThreadObject(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("created_at"u8))
+ {
+ createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64());
+ 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)
+ {
+ 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 AgentThread(
+ id,
+ @object,
+ createdAt,
+ toolResources,
+ 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);
+ default:
+ throw new FormatException($"The model {nameof(AgentThread)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AgentThread IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data);
+ return DeserializeAgentThread(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AgentThread)} 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 AgentThread FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeAgentThread(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/AgentThread.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.cs
new file mode 100644
index 000000000000..1f71977abc81
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThread.cs
@@ -0,0 +1,110 @@
+// 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, AgentThreadObject @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 object type, which is always 'thread'.
+ public AgentThreadObject Object { get; } = AgentThreadObject.Thread;
+
+ /// 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
new file mode 100644
index 000000000000..54e93eb0604e
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadCreationOptions.Serialization.cs
@@ -0,0 +1,208 @@
+// 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)
+ {
+ 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.");
+ }
+
+ writer.WriteStartObject();
+ 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))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ writer.WriteEndObject();
+ }
+
+ 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);
+ 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);
+ 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);
+ 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
new file mode 100644
index 000000000000..384b24441047
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadCreationOptions.cs
@@ -0,0 +1,83 @@
+// 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/AgentThreadObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadObject.cs
new file mode 100644
index 000000000000..031a358c6837
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentThreadObject.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 AgentThread_object.
+ public readonly partial struct AgentThreadObject : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public AgentThreadObject(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string ThreadValue = "thread";
+
+ /// thread.
+ public static AgentThreadObject Thread { get; } = new AgentThreadObject(ThreadValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(AgentThreadObject left, AgentThreadObject right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(AgentThreadObject left, AgentThreadObject right) => !left.Equals(right);
+ /// Converts a to a .
+ public static implicit operator AgentThreadObject(string value) => new AgentThreadObject(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is AgentThreadObject other && Equals(other);
+ ///
+ public bool Equals(AgentThreadObject 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/Agents.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Agents.cs
new file mode 100644
index 000000000000..ce012f356051
--- /dev/null
+++ b/sdk/ai/Azure.AI.Projects/src/Generated/Agents.cs
@@ -0,0 +1,6021 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+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 Agents
+ {
+ 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 Agents for mocking.
+ protected Agents()
+ {
+ }
+
+ /// Initializes a new instance of Agents.
+ /// 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 Studio 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 Studio project name.
+ /// The API version to use for this operation.
+ internal Agents(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("Agents.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("Agents.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(OpenAIPageableListOfAgent.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(OpenAIPageableListOfAgent.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.InternalDeleteThread");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, 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`: Indicates the message is sent by an actual user and should be used in most
+ /// cases to represent user-generated messages.
+ /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert
+ /// messages from the agent into the
+ /// conversation.
+ ///
+ ///
+ /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via
+ /// a separate call to the create message API.
+ ///
+ /// 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, string 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`: Indicates the message is sent by an actual user and should be used in most
+ /// cases to represent user-generated messages.
+ /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert
+ /// messages from the agent into the
+ /// conversation.
+ ///
+ ///
+ /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via
+ /// a separate call to the create message API.
+ ///
+ /// 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, string 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("Agents.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("Agents.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(OpenAIPageableListOfThreadMessage.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(OpenAIPageableListOfThreadMessage.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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("Agents.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.
+ /// 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> 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, IReadOnlyDictionary metadata = 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