diff --git a/sdk/ai/Azure.AI.Assistants/Azure.AI.Assistants.sln b/sdk/ai/Azure.AI.Assistants/Azure.AI.Assistants.sln
new file mode 100644
index 000000000000..7e61ec7e9b4e
--- /dev/null
+++ b/sdk/ai/Azure.AI.Assistants/Azure.AI.Assistants.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.Assistants", "src\Azure.AI.Assistants.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Assistants.Tests", "tests\Azure.AI.Assistants.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.Assistants/CHANGELOG.md b/sdk/ai/Azure.AI.Assistants/CHANGELOG.md
new file mode 100644
index 000000000000..8b33f0fedccc
--- /dev/null
+++ b/sdk/ai/Azure.AI.Assistants/CHANGELOG.md
@@ -0,0 +1,11 @@
+# Release History
+
+## 1.0.0-beta.1 (Unreleased)
+
+### Features Added
+
+### Breaking Changes
+
+### Bugs Fixed
+
+### Other Changes
\ No newline at end of file
diff --git a/sdk/ai/Azure.AI.Assistants/Directory.Build.props b/sdk/ai/Azure.AI.Assistants/Directory.Build.props
new file mode 100644
index 000000000000..63bd836ad44b
--- /dev/null
+++ b/sdk/ai/Azure.AI.Assistants/Directory.Build.props
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/sdk/ai/Azure.AI.Assistants/README.md b/sdk/ai/Azure.AI.Assistants/README.md
new file mode 100644
index 000000000000..a6e83f175c1a
--- /dev/null
+++ b/sdk/ai/Azure.AI.Assistants/README.md
@@ -0,0 +1,107 @@
+# Azure.AI.Assistants client library for .NET
+
+Azure.AI.Assistants 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.Assistants/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.Assistants --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.Assistants/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
+
+
\ No newline at end of file
diff --git a/sdk/ai/Azure.AI.Assistants/src/Azure.AI.Assistants.csproj b/sdk/ai/Azure.AI.Assistants/src/Azure.AI.Assistants.csproj
new file mode 100644
index 000000000000..88d4fd53f671
--- /dev/null
+++ b/sdk/ai/Azure.AI.Assistants/src/Azure.AI.Assistants.csproj
@@ -0,0 +1,20 @@
+
+
+ This is the Azure.AI.Assistants client library for developing .NET applications with rich experience.
+ Azure SDK Code Generation Azure.AI.Assistants for Azure Data Plane
+ 1.0.0-beta.1
+ Azure.AI.Assistants
+ $(RequiredTargetFrameworks)
+ true
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/ai/Azure.AI.Assistants/src/Generated/.Serialization.cs b/sdk/ai/Azure.AI.Assistants/src/Generated/.Serialization.cs
new file mode 100644
index 000000000000..a5fe11cd3d38
--- /dev/null
+++ b/sdk/ai/Azure.AI.Assistants/src/Generated/.Serialization.cs
@@ -0,0 +1,132 @@
+// 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.Assistants
+{
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => (System.ClientModel.Primitives.IJsonModel < Assistants.>this).Write(writer, global::Azure.AI.Assistants.ModelSerializationExtensions.WireOptions);
+
+void global::System.ClientModel.Primitives.IJsonModel.Write(global::System.Text.Json.Utf8JsonWriter writer,global::System.ClientModel.Primitives.ModelReaderWriterOptions options)
+{
+ writer.WriteStartObject();
+ this.JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+/// The JSON writer.
+/// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? (System.ClientModel.Primitives.IPersistableModel < Assistants.>this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(Assistants.)} does not support writing '{format}' format.");
+ }
+
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ Assistants.global::System.ClientModel.Primitives.IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+{
+var format = options.Format == "W" ? (System.ClientModel.Primitives.IPersistableModel < Assistants.>this).GetFormatFromOptions(options) : options.Format;
+if ((format != "J"))
+{
+throw new FormatException($"The model {nameof(global::Azure.AI.Assistants.)} does not support reading '{format}' format.");
+}
+
+using JsonDocument document = JsonDocument.ParseValue(ref reader);
+return Azure.AI.Assistants..Deserialize(document.RootElement, options);
+}
+
+internal static Azure.AI.Assistants.Deserialize(JsonElement element, System.ClientModel.Primitives.ModelReaderWriterOptions options = (ModelReaderWriterOptions)null)
+{
+ options ??= Azure.AI.Assistants.ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == global::System.Text.Json.JsonValueKind.Null)
+ {
+ return null;
+ }
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, global::System.BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new Azure.AI.Assistants.(serializedAdditionalRawData);
+}
+
+BinaryData System.ClientModel.Primitives.IPersistableModel.Write(ModelReaderWriterOptions options)
+{
+ var format = options.Format == "W" ? (System.ClientModel.Primitives.IPersistableModel < Azure.AI.Assistants.>this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(Azure.AI.Assistants.)} does not support writing '{options.Format}' format.");
+ }
+}
+
+Azure.AI.Assistants.global::System.ClientModel.Primitives.IPersistableModel < Azure.AI.Assistants.>.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options)
+{
+ var format = options.Format == "W" ? (System.ClientModel.Primitives.IPersistableModel < Azure.AI.Assistants.>this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, Azure.AI.Assistants.ModelSerializationExtensions.JsonDocumentOptions);
+ return Azure.AI.Assistants..Deserialize(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(Azure.AI.Assistants.)} does not support reading '{options.Format}' format.");
+ }
+}
+
+string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+/// Deserializes the model from a raw response.
+/// The response to deserialize the model from.
+internal static Azure.AI.Assistants.FromResponse(Azure.Response response)
+{
+ using var document = JsonDocument.Parse(response.Content, Azure.AI.Assistants.ModelSerializationExtensions.JsonDocumentOptions);
+ return Azure.AI.Assistants..Deserialize(document.RootElement);
+}
+
+/// Convert into a .
+internal virtual RequestContent ToRequestContent()
+{
+ var content = new Azure.AI.Assistants.Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue < Azure.AI.Assistants.> (this, Azure.AI.Assistants.ModelSerializationExtensions.WireOptions);
+ return content;
+}
+}
+}
diff --git a/sdk/ai/Azure.AI.Assistants/src/Generated/.cs b/sdk/ai/Azure.AI.Assistants/src/Generated/.cs
new file mode 100644
index 000000000000..aacdc88de09b
--- /dev/null
+++ b/sdk/ai/Azure.AI.Assistants/src/Generated/.cs
@@ -0,0 +1,57 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.AI.Assistants
+{
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ internal ()
+{
+}
+
+/// Initializes a new instance of .
+/// Keeps track of any properties unknown to the library.
+internal (IDictionary serializedAdditionalRawData)
+{
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+}
+}
+}
diff --git a/sdk/ai/Azure.AI.Assistants/src/Generated/AIAssistantClient.cs b/sdk/ai/Azure.AI.Assistants/src/Generated/AIAssistantClient.cs
new file mode 100644
index 000000000000..1adae5ec84a4
--- /dev/null
+++ b/sdk/ai/Azure.AI.Assistants/src/Generated/AIAssistantClient.cs
@@ -0,0 +1,6005 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core;
+using Azure.Core.Pipeline;
+
+namespace Azure.AI.Assistants
+{
+ // Data plane generated client.
+ /// The AIAssistant service client.
+ public partial class AIAssistantClient
+ {
+ private const string AuthorizationHeader = "Authorization";
+ private readonly AzureKeyCredential _keyCredential;
+ private const string AuthorizationApiKeyPrefix = "Bearer";
+ private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" };
+ private readonly TokenCredential _tokenCredential;
+ private readonly HttpPipeline _pipeline;
+ private readonly Uri _endpoint;
+ private readonly string _apiVersion;
+
+ /// The ClientDiagnostics is used to provide tracing support for the client library.
+ internal ClientDiagnostics ClientDiagnostics { get; }
+
+ /// The HTTP pipeline for sending and receiving REST requests and responses.
+ public virtual HttpPipeline Pipeline => _pipeline;
+
+ /// Initializes a new instance of AIAssistantClient for mocking.
+ protected AIAssistantClient()
+ {
+ }
+
+ /// Initializes a new instance of AIAssistantClient.
+ /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>.
+ /// A credential used to authenticate to an Azure Service.
+ /// or is null.
+ public AIAssistantClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AIAssistantClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of AIAssistantClient.
+ /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>.
+ /// A credential used to authenticate to an Azure Service.
+ /// or is null.
+ public AIAssistantClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AIAssistantClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of AIAssistantClient.
+ /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>.
+ /// A credential used to authenticate to an Azure Service.
+ /// The options for configuring the client.
+ /// or is null.
+ public AIAssistantClient(Uri endpoint, AzureKeyCredential credential, AIAssistantClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new AIAssistantClientOptions();
+
+ ClientDiagnostics = new ClientDiagnostics(options, true);
+ _keyCredential = credential;
+ _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier());
+ _endpoint = endpoint;
+ _apiVersion = options.Version;
+ }
+
+ /// Initializes a new instance of AIAssistantClient.
+ /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>.
+ /// A credential used to authenticate to an Azure Service.
+ /// The options for configuring the client.
+ /// or is null.
+ public AIAssistantClient(Uri endpoint, TokenCredential credential, AIAssistantClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new AIAssistantClientOptions();
+
+ ClientDiagnostics = new ClientDiagnostics(options, true);
+ _tokenCredential = credential;
+ _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
+ _endpoint = endpoint;
+ _apiVersion = options.Version;
+ }
+
+ /// 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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.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("AIAssistantClient.UpdateMessage");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Creates a new run for an agent thread.
+ /// Identifier of the thread.
+ /// The ID of the agent that should run the thread.
+ /// The overridden model name that the agent should use to run the thread.
+ /// The overridden system instructions that the agent should use to run the thread.
+ ///
+ /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior
+ /// on a per-run basis without overriding other instructions.
+ ///
+ /// Adds additional messages to the thread before creating the run.
+ /// The overridden list of enabled tools that the agent should use to run the thread.
+ ///
+ /// If `true`, returns a stream of events that happen during the Run as server-sent events,
+ /// terminating when the Run enters a terminal state with a `data: [DONE]` message.
+ ///
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output
+ /// more random, while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model
+ /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens
+ /// comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ ///
+ /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only
+ /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified,
+ /// the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ ///
+ /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort
+ /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of
+ /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ /// The strategy to use for dropping messages as the context windows moves forward.
+ /// Controls whether or not and which tool is called by the model.
+ /// Specifies the format that the model must output.
+ /// If `true` functions will run in parallel during tool use.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> CreateRunAsync(string threadId, string assistantId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, IEnumerable include = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNull(assistantId, nameof(assistantId));
+
+ CreateRunRequest createRunRequest = new CreateRunRequest(
+ assistantId,
+ overrideModelName,
+ overrideInstructions,
+ additionalInstructions,
+ additionalMessages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(),
+ overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(),
+ stream,
+ temperature,
+ topP,
+ maxPromptTokens,
+ maxCompletionTokens,
+ truncationStrategy,
+ toolChoice,
+ responseFormat,
+ parallelToolCalls,
+ metadata ?? new ChangeTrackingDictionary(),
+ null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CreateRunAsync(threadId, createRunRequest.ToRequestContent(), include, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ /// Creates a new run for an agent thread.
+ /// Identifier of the thread.
+ /// The ID of the agent that should run the thread.
+ /// The overridden model name that the agent should use to run the thread.
+ /// The overridden system instructions that the agent should use to run the thread.
+ ///
+ /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior
+ /// on a per-run basis without overriding other instructions.
+ ///
+ /// Adds additional messages to the thread before creating the run.
+ /// The overridden list of enabled tools that the agent should use to run the thread.
+ ///
+ /// If `true`, returns a stream of events that happen during the Run as server-sent events,
+ /// terminating when the Run enters a terminal state with a `data: [DONE]` message.
+ ///
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output
+ /// more random, while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model
+ /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens
+ /// comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ ///
+ /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only
+ /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified,
+ /// the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ ///
+ /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort
+ /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of
+ /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ /// The strategy to use for dropping messages as the context windows moves forward.
+ /// Controls whether or not and which tool is called by the model.
+ /// Specifies the format that the model must output.
+ /// If `true` functions will run in parallel during tool use.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response CreateRun(string threadId, string assistantId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, IEnumerable include = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNull(assistantId, nameof(assistantId));
+
+ CreateRunRequest createRunRequest = new CreateRunRequest(
+ assistantId,
+ overrideModelName,
+ overrideInstructions,
+ additionalInstructions,
+ additionalMessages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(),
+ overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(),
+ stream,
+ temperature,
+ topP,
+ maxPromptTokens,
+ maxCompletionTokens,
+ truncationStrategy,
+ toolChoice,
+ responseFormat,
+ parallelToolCalls,
+ metadata ?? new ChangeTrackingDictionary(),
+ null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CreateRun(threadId, createRunRequest.ToRequestContent(), include, context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Creates a new run for an agent thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// The content to send as the body of the request.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task CreateRunAsync(string threadId, RequestContent content, IEnumerable include = null, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateRunRequest(threadId, content, include, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Creates a new run for an agent thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// The content to send as the body of the request.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response CreateRun(string threadId, RequestContent content, IEnumerable include = null, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateRunRequest(threadId, content, include, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets a list of runs for a specified thread.
+ /// Identifier of the thread.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual async Task> InternalGetRunsAsync(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await InternalGetRunsAsync(threadId, limit, order?.ToString(), after, before, context).ConfigureAwait(false);
+ return Response.FromValue(OpenAIPageableListOfThreadRun.FromResponse(response), response);
+ }
+
+ /// Gets a list of runs for a specified thread.
+ /// Identifier of the thread.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual Response InternalGetRuns(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = InternalGetRuns(threadId, limit, order?.ToString(), after, before, context);
+ return Response.FromValue(OpenAIPageableListOfThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of runs for a specified thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task InternalGetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.InternalGetRuns");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of runs for a specified thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response InternalGetRuns(string threadId, int? limit, string order, string after, string before, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.InternalGetRuns");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets an existing run from an existing thread.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetRunAsync(string threadId, string runId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetRunAsync(threadId, runId, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ /// Gets an existing run from an existing thread.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetRun(string threadId, string runId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetRun(threadId, runId, context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets an existing run from an existing thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetRunAsync(string threadId, string runId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetRunRequest(threadId, runId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Gets an existing run from an existing thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetRun(string threadId, string runId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetRunRequest(threadId, runId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Modifies an existing thread run.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> UpdateRunAsync(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await UpdateRunAsync(threadId, runId, updateRunRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ /// Modifies an existing thread run.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response UpdateRun(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = UpdateRun(threadId, runId, updateRunRequest.ToRequestContent(), context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Modifies an existing thread run.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task UpdateRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.UpdateRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Modifies an existing thread run.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response UpdateRun(string threadId, string runId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.UpdateRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// A list of tools for which the outputs are being submitted.
+ /// If true, returns a stream of events that happen during the Run as server-sent events, terminating when the run enters a terminal state.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> SubmitToolOutputsToRunAsync(string threadId, string runId, IEnumerable toolOutputs, bool? stream = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(toolOutputs, nameof(toolOutputs));
+
+ SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), stream, null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await SubmitToolOutputsToRunAsync(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ /// Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// A list of tools for which the outputs are being submitted.
+ /// If true, returns a stream of events that happen during the Run as server-sent events, terminating when the run enters a terminal state.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response SubmitToolOutputsToRun(string threadId, string runId, IEnumerable toolOutputs, bool? stream = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(toolOutputs, nameof(toolOutputs));
+
+ SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), stream, null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = SubmitToolOutputsToRun(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task SubmitToolOutputsToRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.SubmitToolOutputsToRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response SubmitToolOutputsToRun(string threadId, string runId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.SubmitToolOutputsToRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Cancels a run of an in progress thread.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> CancelRunAsync(string threadId, string runId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CancelRunAsync(threadId, runId, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ /// Cancels a run of an in progress thread.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response CancelRun(string threadId, string runId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CancelRun(threadId, runId, context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Cancels a run of an in progress thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task CancelRunAsync(string threadId, string runId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CancelRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCancelRunRequest(threadId, runId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Cancels a run of an in progress thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response CancelRun(string threadId, string runId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CancelRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCancelRunRequest(threadId, runId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Creates a new agent thread and immediately starts a run using that new thread.
+ /// The ID of the agent for which the thread should be created.
+ /// The details used to create the new thread. If no thread is provided, an empty one will be created.
+ /// The overridden model that the agent should use to run the thread.
+ /// The overridden system instructions the agent should use to run the thread.
+ /// The overridden list of enabled tools the agent should use to run the thread.
+ /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis.
+ ///
+ /// If `true`, returns a stream of events that happen during the Run as server-sent events,
+ /// terminating when the Run enters a terminal state with a `data: [DONE]` message.
+ ///
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output
+ /// more random, while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model
+ /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens
+ /// comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ ///
+ /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only
+ /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified,
+ /// the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ ///
+ /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only
+ /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens
+ /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ /// The strategy to use for dropping messages as the context windows moves forward.
+ /// Controls whether or not and which tool is called by the model.
+ /// Specifies the format that the model must output.
+ /// If `true` functions will run in parallel during tool use.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual async Task> CreateThreadAndRunAsync(string assistantId, AgentThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, UpdateToolResourcesOptions toolResources = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(assistantId, nameof(assistantId));
+
+ CreateThreadAndRunRequest createThreadAndRunRequest = new CreateThreadAndRunRequest(
+ assistantId,
+ thread,
+ overrideModelName,
+ overrideInstructions,
+ overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(),
+ toolResources,
+ stream,
+ temperature,
+ topP,
+ maxPromptTokens,
+ maxCompletionTokens,
+ truncationStrategy,
+ toolChoice,
+ responseFormat,
+ parallelToolCalls,
+ metadata ?? new ChangeTrackingDictionary(),
+ null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CreateThreadAndRunAsync(createThreadAndRunRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ /// Creates a new agent thread and immediately starts a run using that new thread.
+ /// The ID of the agent for which the thread should be created.
+ /// The details used to create the new thread. If no thread is provided, an empty one will be created.
+ /// The overridden model that the agent should use to run the thread.
+ /// The overridden system instructions the agent should use to run the thread.
+ /// The overridden list of enabled tools the agent should use to run the thread.
+ /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis.
+ ///
+ /// If `true`, returns a stream of events that happen during the Run as server-sent events,
+ /// terminating when the Run enters a terminal state with a `data: [DONE]` message.
+ ///
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output
+ /// more random, while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model
+ /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens
+ /// comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ ///
+ /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only
+ /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified,
+ /// the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ ///
+ /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only
+ /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens
+ /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ /// The strategy to use for dropping messages as the context windows moves forward.
+ /// Controls whether or not and which tool is called by the model.
+ /// Specifies the format that the model must output.
+ /// If `true` functions will run in parallel during tool use.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual Response CreateThreadAndRun(string assistantId, AgentThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, UpdateToolResourcesOptions toolResources = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(assistantId, nameof(assistantId));
+
+ CreateThreadAndRunRequest createThreadAndRunRequest = new CreateThreadAndRunRequest(
+ assistantId,
+ thread,
+ overrideModelName,
+ overrideInstructions,
+ overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(),
+ toolResources,
+ stream,
+ temperature,
+ topP,
+ maxPromptTokens,
+ maxCompletionTokens,
+ truncationStrategy,
+ toolChoice,
+ responseFormat,
+ parallelToolCalls,
+ metadata ?? new ChangeTrackingDictionary(),
+ null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CreateThreadAndRun(createThreadAndRunRequest.ToRequestContent(), context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Creates a new agent thread and immediately starts a run using that new thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task CreateThreadAndRunAsync(RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateThreadAndRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateThreadAndRunRequest(content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Creates a new agent thread and immediately starts a run using that new thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response CreateThreadAndRun(RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateThreadAndRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateThreadAndRunRequest(content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets a single run step from a thread run.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// Identifier of the run step.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// The cancellation token to use.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetRunStepAsync(string threadId, string runId, string stepId, IEnumerable include = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNullOrEmpty(stepId, nameof(stepId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetRunStepAsync(threadId, runId, stepId, include, context).ConfigureAwait(false);
+ return Response.FromValue(RunStep.FromResponse(response), response);
+ }
+
+ /// Gets a single run step from a thread run.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// Identifier of the run step.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// The cancellation token to use.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetRunStep(string threadId, string runId, string stepId, IEnumerable include = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNullOrEmpty(stepId, nameof(stepId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetRunStep(threadId, runId, stepId, include, context);
+ return Response.FromValue(RunStep.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets a single run step from a thread run.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// Identifier of the run step.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetRunStepAsync(string threadId, string runId, string stepId, IEnumerable include, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNullOrEmpty(stepId, nameof(stepId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetRunStep");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, include, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Gets a single run step from a thread run.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ /// Identifier of the run step.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetRunStep(string threadId, string runId, string stepId, IEnumerable include, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNullOrEmpty(stepId, nameof(stepId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetRunStep");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, include, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets a list of run steps from a thread run.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual async Task> InternalGetRunStepsAsync(string threadId, string runId, IEnumerable include = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await InternalGetRunStepsAsync(threadId, runId, include, limit, order?.ToString(), after, before, context).ConfigureAwait(false);
+ return Response.FromValue(OpenAIPageableListOfRunStep.FromResponse(response), response);
+ }
+
+ /// Gets a list of run steps from a thread run.
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual Response InternalGetRunSteps(string threadId, string runId, IEnumerable include = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = InternalGetRunSteps(threadId, runId, include, limit, order?.ToString(), after, before, context);
+ return Response.FromValue(OpenAIPageableListOfRunStep.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of run steps from a thread run.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task InternalGetRunStepsAsync(string threadId, string runId, IEnumerable include, int? limit, string order, string after, string before, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.InternalGetRunSteps");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, include, limit, order, after, before, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of run steps from a thread run.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the thread.
+ /// Identifier of the run.
+ ///
+ /// A list of additional fields to include in the response.
+ /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.
+ ///
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response InternalGetRunSteps(string threadId, string runId, IEnumerable include, int? limit, string order, string after, string before, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.InternalGetRunSteps");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, include, limit, order, after, before, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets a list of previously uploaded files.
+ /// The purpose of the file.
+ /// The cancellation token to use.
+ internal virtual async Task> InternalListFilesAsync(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default)
+ {
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await InternalListFilesAsync(purpose?.ToString(), context).ConfigureAwait(false);
+ return Response.FromValue(InternalFileListResponse.FromResponse(response), response);
+ }
+
+ /// Gets a list of previously uploaded files.
+ /// The purpose of the file.
+ /// The cancellation token to use.
+ internal virtual Response InternalListFiles(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default)
+ {
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = InternalListFiles(purpose?.ToString(), context);
+ return Response.FromValue(InternalFileListResponse.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of previously uploaded files.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The purpose of the file. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output" | "batch" | "batch_output" | "vision".
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task InternalListFilesAsync(string purpose, RequestContext context)
+ {
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.InternalListFiles");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalListFilesRequest(purpose, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of previously uploaded files.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The purpose of the file. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output" | "batch" | "batch_output" | "vision".
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response InternalListFiles(string purpose, RequestContext context)
+ {
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.InternalListFiles");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalListFilesRequest(purpose, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Uploads a file for use by other operations.
+ /// Multipart body.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual async Task> UploadFileAsync(UploadFileRequest body, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(body, nameof(body));
+
+ using MultipartFormDataRequestContent content = body.ToMultipartRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await UploadFileAsync(content, content.ContentType, context).ConfigureAwait(false);
+ return Response.FromValue(OpenAIFile.FromResponse(response), response);
+ }
+
+ /// Uploads a file for use by other operations.
+ /// Multipart body.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual Response UploadFile(UploadFileRequest body, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(body, nameof(body));
+
+ using MultipartFormDataRequestContent content = body.ToMultipartRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = UploadFile(content, content.ContentType, context);
+ return Response.FromValue(OpenAIFile.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Uploads a file for use by other operations.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The content to send as the body of the request.
+ /// The name of the file to upload. Allowed values: "multipart/form-data".
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task UploadFileAsync(RequestContent content, string contentType, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.UploadFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateUploadFileRequest(content, contentType, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Uploads a file for use by other operations.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The content to send as the body of the request.
+ /// The name of the file to upload. Allowed values: "multipart/form-data".
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response UploadFile(RequestContent content, string contentType, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.UploadFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateUploadFileRequest(content, contentType, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Delete a previously uploaded file.
+ /// The ID of the file to delete.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual async Task> InternalDeleteFileAsync(string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await InternalDeleteFileAsync(fileId, context).ConfigureAwait(false);
+ return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response);
+ }
+
+ /// Delete a previously uploaded file.
+ /// The ID of the file to delete.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual Response InternalDeleteFile(string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = InternalDeleteFile(fileId, context);
+ return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Delete a previously uploaded file.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the file to delete.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task InternalDeleteFileAsync(string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.InternalDeleteFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Delete a previously uploaded file.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the file to delete.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response InternalDeleteFile(string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.InternalDeleteFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Returns information about a specific file. Does not retrieve file content.
+ /// The ID of the file to retrieve.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetFileAsync(string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetFileAsync(fileId, context).ConfigureAwait(false);
+ return Response.FromValue(OpenAIFile.FromResponse(response), response);
+ }
+
+ /// Returns information about a specific file. Does not retrieve file content.
+ /// The ID of the file to retrieve.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetFile(string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetFile(fileId, context);
+ return Response.FromValue(OpenAIFile.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Returns information about a specific file. Does not retrieve file content.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the file to retrieve.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetFileAsync(string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetFileRequest(fileId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Returns information about a specific file. Does not retrieve file content.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the file to retrieve.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetFile(string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetFileRequest(fileId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Retrieves the raw content of a specific file.
+ /// The ID of the file to retrieve.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetFileContentAsync(string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetFileContentAsync(fileId, context).ConfigureAwait(false);
+ return Response.FromValue(response.Content, response);
+ }
+
+ /// Retrieves the raw content of a specific file.
+ /// The ID of the file to retrieve.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetFileContent(string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetFileContent(fileId, context);
+ return Response.FromValue(response.Content, response);
+ }
+
+ ///
+ /// [Protocol Method] Retrieves the raw content of a specific file.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the file to retrieve.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetFileContentAsync(string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetFileContent");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetFileContentRequest(fileId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Retrieves the raw content of a specific file.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the file to retrieve.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetFileContent(string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetFileContent");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetFileContentRequest(fileId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Returns a list of vector stores.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The cancellation token to use.
+ ///
+ public virtual async Task> GetVectorStoresAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetVectorStoresAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false);
+ return Response.FromValue(OpenAIPageableListOfVectorStore.FromResponse(response), response);
+ }
+
+ /// Returns a list of vector stores.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The cancellation token to use.
+ ///
+ public virtual Response GetVectorStores(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetVectorStores(limit, order?.ToString(), after, before, context);
+ return Response.FromValue(OpenAIPageableListOfVectorStore.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Returns a list of vector stores.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetVectorStoresAsync(int? limit, string order, string after, string before, RequestContext context)
+ {
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStores");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoresRequest(limit, order, after, before, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Returns a list of vector stores.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetVectorStores(int? limit, string order, string after, string before, RequestContext context)
+ {
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStores");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoresRequest(limit, order, after, before, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Creates a vector store.
+ /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files.
+ /// The name of the vector store.
+ /// The vector store configuration, used when vector store is created from Azure asset URIs.
+ /// Details on when this vector store expires.
+ /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ ///
+ public virtual async Task> CreateVectorStoreAsync(IEnumerable fileIds = null, string name = null, VectorStoreConfiguration storeConfiguration = null, VectorStoreExpirationPolicy expiresAfter = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ {
+ CreateVectorStoreRequest createVectorStoreRequest = new CreateVectorStoreRequest(
+ fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(),
+ name,
+ storeConfiguration,
+ expiresAfter,
+ chunkingStrategy,
+ metadata ?? new ChangeTrackingDictionary(),
+ null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CreateVectorStoreAsync(createVectorStoreRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(VectorStore.FromResponse(response), response);
+ }
+
+ /// Creates a vector store.
+ /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files.
+ /// The name of the vector store.
+ /// The vector store configuration, used when vector store is created from Azure asset URIs.
+ /// Details on when this vector store expires.
+ /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ ///
+ public virtual Response CreateVectorStore(IEnumerable fileIds = null, string name = null, VectorStoreConfiguration storeConfiguration = null, VectorStoreExpirationPolicy expiresAfter = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ {
+ CreateVectorStoreRequest createVectorStoreRequest = new CreateVectorStoreRequest(
+ fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(),
+ name,
+ storeConfiguration,
+ expiresAfter,
+ chunkingStrategy,
+ metadata ?? new ChangeTrackingDictionary(),
+ null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CreateVectorStore(createVectorStoreRequest.ToRequestContent(), context);
+ return Response.FromValue(VectorStore.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Creates a vector store.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task CreateVectorStoreAsync(RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateVectorStore");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateVectorStoreRequest(content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Creates a vector store.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response CreateVectorStore(RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateVectorStore");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateVectorStoreRequest(content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Returns the vector store object matching the specified ID.
+ /// Identifier of the vector store.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetVectorStoreAsync(string vectorStoreId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetVectorStoreAsync(vectorStoreId, context).ConfigureAwait(false);
+ return Response.FromValue(VectorStore.FromResponse(response), response);
+ }
+
+ /// Returns the vector store object matching the specified ID.
+ /// Identifier of the vector store.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetVectorStore(string vectorStoreId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetVectorStore(vectorStoreId, context);
+ return Response.FromValue(VectorStore.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Returns the vector store object matching the specified ID.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetVectorStoreAsync(string vectorStoreId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStore");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoreRequest(vectorStoreId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Returns the vector store object matching the specified ID.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetVectorStore(string vectorStoreId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStore");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoreRequest(vectorStoreId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// The ID of the vector store to modify.
+ /// Identifier of the vector store.
+ /// The name of the vector store.
+ /// Details on when this vector store expires.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> ModifyVectorStoreAsync(string vectorStoreId, string name = null, VectorStoreExpirationPolicy expiresAfter = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ ModifyVectorStoreRequest modifyVectorStoreRequest = new ModifyVectorStoreRequest(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await ModifyVectorStoreAsync(vectorStoreId, modifyVectorStoreRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(VectorStore.FromResponse(response), response);
+ }
+
+ /// The ID of the vector store to modify.
+ /// Identifier of the vector store.
+ /// The name of the vector store.
+ /// Details on when this vector store expires.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response ModifyVectorStore(string vectorStoreId, string name = null, VectorStoreExpirationPolicy expiresAfter = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ ModifyVectorStoreRequest modifyVectorStoreRequest = new ModifyVectorStoreRequest(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = ModifyVectorStore(vectorStoreId, modifyVectorStoreRequest.ToRequestContent(), context);
+ return Response.FromValue(VectorStore.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] The ID of the vector store to modify.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task ModifyVectorStoreAsync(string vectorStoreId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.ModifyVectorStore");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] The ID of the vector store to modify.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response ModifyVectorStore(string vectorStoreId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.ModifyVectorStore");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Deletes the vector store object matching the specified ID.
+ /// Identifier of the vector store.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> DeleteVectorStoreAsync(string vectorStoreId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await DeleteVectorStoreAsync(vectorStoreId, context).ConfigureAwait(false);
+ return Response.FromValue(VectorStoreDeletionStatus.FromResponse(response), response);
+ }
+
+ /// Deletes the vector store object matching the specified ID.
+ /// Identifier of the vector store.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response DeleteVectorStore(string vectorStoreId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = DeleteVectorStore(vectorStoreId, context);
+ return Response.FromValue(VectorStoreDeletionStatus.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Deletes the vector store object matching the specified ID.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task DeleteVectorStoreAsync(string vectorStoreId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.DeleteVectorStore");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Deletes the vector store object matching the specified ID.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response DeleteVectorStore(string vectorStoreId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.DeleteVectorStore");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Returns a list of vector store files.
+ /// Identifier of the vector store.
+ /// Filter by file status.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetVectorStoreFilesAsync(string vectorStoreId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetVectorStoreFilesAsync(vectorStoreId, filter?.ToString(), limit, order?.ToString(), after, before, context).ConfigureAwait(false);
+ return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response);
+ }
+
+ /// Returns a list of vector store files.
+ /// Identifier of the vector store.
+ /// Filter by file status.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetVectorStoreFiles(string vectorStoreId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetVectorStoreFiles(vectorStoreId, filter?.ToString(), limit, order?.ToString(), after, before, context);
+ return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Returns a list of vector store files.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled".
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetVectorStoreFilesAsync(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStoreFiles");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, filter, limit, order, after, before, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Returns a list of vector store files.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled".
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetVectorStoreFiles(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStoreFiles");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, filter, limit, order, after, before, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Create a vector store file by attaching a file to a vector store.
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// Azure asset ID.
+ /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> CreateVectorStoreFileAsync(string vectorStoreId, string fileId = null, VectorStoreDataSource dataSource = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ CreateVectorStoreFileRequest createVectorStoreFileRequest = new CreateVectorStoreFileRequest(fileId, dataSource, chunkingStrategy, null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CreateVectorStoreFileAsync(vectorStoreId, createVectorStoreFileRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(VectorStoreFile.FromResponse(response), response);
+ }
+
+ /// Create a vector store file by attaching a file to a vector store.
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// Azure asset ID.
+ /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response CreateVectorStoreFile(string vectorStoreId, string fileId = null, VectorStoreDataSource dataSource = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ CreateVectorStoreFileRequest createVectorStoreFileRequest = new CreateVectorStoreFileRequest(fileId, dataSource, chunkingStrategy, null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CreateVectorStoreFile(vectorStoreId, createVectorStoreFileRequest.ToRequestContent(), context);
+ return Response.FromValue(VectorStoreFile.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Create a vector store file by attaching a file to a vector store.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task CreateVectorStoreFileAsync(string vectorStoreId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateVectorStoreFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Create a vector store file by attaching a file to a vector store.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response CreateVectorStoreFile(string vectorStoreId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateVectorStoreFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Retrieves a vector store file.
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetVectorStoreFileAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetVectorStoreFileAsync(vectorStoreId, fileId, context).ConfigureAwait(false);
+ return Response.FromValue(VectorStoreFile.FromResponse(response), response);
+ }
+
+ /// Retrieves a vector store file.
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetVectorStoreFile(string vectorStoreId, string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetVectorStoreFile(vectorStoreId, fileId, context);
+ return Response.FromValue(VectorStoreFile.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Retrieves a vector store file.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetVectorStoreFileAsync(string vectorStoreId, string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStoreFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoreFileRequest(vectorStoreId, fileId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Retrieves a vector store file.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetVectorStoreFile(string vectorStoreId, string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStoreFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoreFileRequest(vectorStoreId, fileId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted.
+ /// To delete the file, use the delete file endpoint.
+ ///
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> DeleteVectorStoreFileAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await DeleteVectorStoreFileAsync(vectorStoreId, fileId, context).ConfigureAwait(false);
+ return Response.FromValue(VectorStoreFileDeletionStatus.FromResponse(response), response);
+ }
+
+ ///
+ /// Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted.
+ /// To delete the file, use the delete file endpoint.
+ ///
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response DeleteVectorStoreFile(string vectorStoreId, string fileId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = DeleteVectorStoreFile(vectorStoreId, fileId, context);
+ return Response.FromValue(VectorStoreFileDeletionStatus.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted.
+ /// To delete the file, use the delete file endpoint.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task DeleteVectorStoreFileAsync(string vectorStoreId, string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.DeleteVectorStoreFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted.
+ /// To delete the file, use the delete file endpoint.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// Identifier of the file.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response DeleteVectorStoreFile(string vectorStoreId, string fileId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.DeleteVectorStoreFile");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Create a vector store file batch.
+ /// Identifier of the vector store.
+ /// List of file identifiers.
+ /// List of Azure assets.
+ /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> CreateVectorStoreFileBatchAsync(string vectorStoreId, IEnumerable fileIds = null, IEnumerable dataSources = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequest = new CreateVectorStoreFileBatchRequest(fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), dataSources?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), chunkingStrategy, null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CreateVectorStoreFileBatchAsync(vectorStoreId, createVectorStoreFileBatchRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response);
+ }
+
+ /// Create a vector store file batch.
+ /// Identifier of the vector store.
+ /// List of file identifiers.
+ /// List of Azure assets.
+ /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response CreateVectorStoreFileBatch(string vectorStoreId, IEnumerable fileIds = null, IEnumerable dataSources = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+
+ CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequest = new CreateVectorStoreFileBatchRequest(fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), dataSources?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), chunkingStrategy, null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CreateVectorStoreFileBatch(vectorStoreId, createVectorStoreFileBatchRequest.ToRequestContent(), context);
+ return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Create a vector store file batch.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task CreateVectorStoreFileBatchAsync(string vectorStoreId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateVectorStoreFileBatch");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Create a vector store file batch.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response CreateVectorStoreFileBatch(string vectorStoreId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.CreateVectorStoreFileBatch");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Retrieve a vector store file batch.
+ /// Identifier of the vector store.
+ /// Identifier of the file batch.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetVectorStoreFileBatchAsync(string vectorStoreId, string batchId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(batchId, nameof(batchId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetVectorStoreFileBatchAsync(vectorStoreId, batchId, context).ConfigureAwait(false);
+ return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response);
+ }
+
+ /// Retrieve a vector store file batch.
+ /// Identifier of the vector store.
+ /// Identifier of the file batch.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetVectorStoreFileBatch(string vectorStoreId, string batchId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(batchId, nameof(batchId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetVectorStoreFileBatch(vectorStoreId, batchId, context);
+ return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Retrieve a vector store file batch.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Identifier of the vector store.
+ /// Identifier of the file batch.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetVectorStoreFileBatchAsync(string vectorStoreId, string batchId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId));
+ Argument.AssertNotNullOrEmpty(batchId, nameof(batchId));
+
+ using var scope = ClientDiagnostics.CreateScope("AIAssistantClient.GetVectorStoreFileBatch");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetVectorStoreFileBatchRequest(vectorStoreId, batchId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Retrieve a vector store file batch.
+ ///
+ /// -
+ ///
+ /// This