openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Assistants/Internal/InternalAssistantThreadClient.cs
62lines · modecode
| 1 | using System; |
| 2 | using System.ClientModel; |
| 3 | using System.ClientModel.Primitives; |
| 4 | using System.Threading; |
| 5 | |
| 6 | namespace OpenAI.Assistants; |
| 7 | |
| 8 | [CodeGenClient("Threads")] |
| 9 | [CodeGenSuppress("InternalAssistantThreadClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))] |
| 10 | [CodeGenSuppress("CreateThreadAsync", typeof(ThreadCreationOptions), typeof(CancellationToken))] |
| 11 | [CodeGenSuppress("CreateThread", typeof(ThreadCreationOptions), typeof(CancellationToken))] |
| 12 | [CodeGenSuppress("GetThreadAsync", typeof(string), typeof(CancellationToken))] |
| 13 | [CodeGenSuppress("GetThread", typeof(string), typeof(CancellationToken))] |
| 14 | [CodeGenSuppress("ModifyThreadAsync", typeof(string), typeof(ThreadModificationOptions), typeof(CancellationToken))] |
| 15 | [CodeGenSuppress("ModifyThread", typeof(string), typeof(ThreadModificationOptions), typeof(CancellationToken))] |
| 16 | [CodeGenSuppress("DeleteThreadAsync", typeof(string), typeof(CancellationToken))] |
| 17 | [CodeGenSuppress("DeleteThread", typeof(string), typeof(CancellationToken))] |
| 18 | internal partial class InternalAssistantThreadClient |
| 19 | { |
| 20 | // CUSTOM: |
| 21 | // - Used a custom pipeline. |
| 22 | // - Demoted the endpoint parameter to be a property in the options class. |
| 23 | /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient"/>. </summary> |
| 24 | /// <param name="credential"> The API key to authenticate with the service. </param> |
| 25 | /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception> |
| 26 | public InternalAssistantThreadClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | // CUSTOM: |
| 31 | // - Used a custom pipeline. |
| 32 | // - Demoted the endpoint parameter to be a property in the options class. |
| 33 | /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient"/>. </summary> |
| 34 | /// <param name="credential"> The API key to authenticate with the service. </param> |
| 35 | /// <param name="options"> The options to configure the client. </param> |
| 36 | /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception> |
| 37 | public InternalAssistantThreadClient(ApiKeyCredential credential, OpenAIClientOptions options) |
| 38 | { |
| 39 | Argument.AssertNotNull(credential, nameof(credential)); |
| 40 | options ??= new OpenAIClientOptions(); |
| 41 | |
| 42 | Pipeline = OpenAIClient.CreatePipeline(credential, options); |
| 43 | _endpoint = OpenAIClient.GetEndpoint(options); |
| 44 | } |
| 45 | |
| 46 | // CUSTOM: |
| 47 | // - Used a custom pipeline. |
| 48 | // - Demoted the endpoint parameter to be a property in the options class. |
| 49 | // - Made protected. |
| 50 | /// <summary> Initializes a new instance of <see cref="InternalAssistantThreadClient"/>. </summary> |
| 51 | /// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param> |
| 52 | /// <param name="options"> The options to configure the client. </param> |
| 53 | /// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception> |
| 54 | protected internal InternalAssistantThreadClient(ClientPipeline pipeline, OpenAIClientOptions options) |
| 55 | { |
| 56 | Argument.AssertNotNull(pipeline, nameof(pipeline)); |
| 57 | options ??= new OpenAIClientOptions(); |
| 58 | |
| 59 | Pipeline = pipeline; |
| 60 | _endpoint = OpenAIClient.GetEndpoint(options); |
| 61 | } |
| 62 | } |
| 63 | |