openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.0.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/Custom/Assistants/Internal/InternalAssistantRunClient.cs

77lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4
5namespace OpenAI.Assistants;
6
7[CodeGenClient("Runs")]
8[CodeGenSuppress("InternalAssistantRunClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
9[CodeGenSuppress("CreateThreadAndRunAsync", typeof(InternalCreateThreadAndRunRequest))]
10[CodeGenSuppress("CreateThreadAndRun", typeof(InternalCreateThreadAndRunRequest))]
11[CodeGenSuppress("CreateRunAsync", typeof(string), typeof(RunCreationOptions))]
12[CodeGenSuppress("CreateRun", typeof(string), typeof(RunCreationOptions))]
13[CodeGenSuppress("GetRunsAsync", typeof(string), typeof(int?), typeof(RunCollectionOrder?), typeof(string), typeof(string))]
14[CodeGenSuppress("GetRuns", typeof(string), typeof(int?), typeof(RunCollectionOrder?), typeof(string), typeof(string))]
15[CodeGenSuppress("GetRunAsync", typeof(string), typeof(string))]
16[CodeGenSuppress("GetRun", typeof(string), typeof(string))]
17[CodeGenSuppress("ModifyRunAsync", typeof(string), typeof(string), typeof(RunModificationOptions))]
18[CodeGenSuppress("ModifyRun", typeof(string), typeof(string), typeof(RunModificationOptions))]
19[CodeGenSuppress("CancelRunAsync", typeof(string), typeof(string))]
20[CodeGenSuppress("CancelRun", typeof(string), typeof(string))]
21[CodeGenSuppress("SubmitToolOutputsToRunAsync", typeof(string), typeof(string), typeof(InternalSubmitToolOutputsRunRequest))]
22[CodeGenSuppress("SubmitToolOutputsToRun", typeof(string), typeof(string), typeof(InternalSubmitToolOutputsRunRequest))]
23[CodeGenSuppress("GetRunStepsAsync", typeof(string), typeof(string), typeof(int?), typeof(RunStepCollectionOrder?), typeof(string), typeof(string))]
24[CodeGenSuppress("GetRunSteps", typeof(string), typeof(string), typeof(int?), typeof(RunStepCollectionOrder?), typeof(string), typeof(string))]
25[CodeGenSuppress("GetRunStepAsync", typeof(string), typeof(string), typeof(string))]
26[CodeGenSuppress("GetRunStep", typeof(string), typeof(string), typeof(string))]
27internal partial class InternalAssistantRunClient
28{
29 // CUSTOM: Remove virtual keyword.
30 /// <summary>
31 /// The HTTP pipeline for sending and receiving REST requests and responses.
32 /// </summary>
33 public ClientPipeline Pipeline => _pipeline;
34
35 // CUSTOM:
36 // - Used a custom pipeline.
37 // - Demoted the endpoint parameter to be a property in the options class.
38 /// <summary> Initializes a new instance of <see cref="InternalAssistantRunClient">. </summary>
39 /// <param name="credential"> The API key to authenticate with the service. </param>
40 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
41 public InternalAssistantRunClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions())
42 {
43 }
44
45 // CUSTOM:
46 // - Used a custom pipeline.
47 // - Demoted the endpoint parameter to be a property in the options class.
48 /// <summary> Initializes a new instance of <see cref="InternalAssistantRunClient">. </summary>
49 /// <param name="credential"> The API key to authenticate with the service. </param>
50 /// <param name="options"> The options to configure the client. </param>
51 /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception>
52 public InternalAssistantRunClient(ApiKeyCredential credential, OpenAIClientOptions options)
53 {
54 Argument.AssertNotNull(credential, nameof(credential));
55 options ??= new OpenAIClientOptions();
56
57 _pipeline = OpenAIClient.CreatePipeline(credential, options);
58 _endpoint = OpenAIClient.GetEndpoint(options);
59 }
60
61 // CUSTOM:
62 // - Used a custom pipeline.
63 // - Demoted the endpoint parameter to be a property in the options class.
64 // - Made protected.
65 /// <summary> Initializes a new instance of <see cref="InternalAssistantRunClient">. </summary>
66 /// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param>
67 /// <param name="options"> The options to configure the client. </param>
68 /// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception>
69 protected internal InternalAssistantRunClient(ClientPipeline pipeline, OpenAIClientOptions options)
70 {
71 Argument.AssertNotNull(pipeline, nameof(pipeline));
72 options ??= new OpenAIClientOptions();
73
74 _pipeline = pipeline;
75 _endpoint = OpenAIClient.GetEndpoint(options);
76 }
77}
78