openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Generated/ChatClient.cs
94lines · modecode
| 1 | // <auto-generated/> |
| 2 | |
| 3 | #nullable disable |
| 4 | |
| 5 | using System; |
| 6 | using System.ClientModel; |
| 7 | using System.ClientModel.Primitives; |
| 8 | using System.Collections.Generic; |
| 9 | using System.Diagnostics.CodeAnalysis; |
| 10 | using System.Threading; |
| 11 | using System.Threading.Tasks; |
| 12 | using OpenAI; |
| 13 | |
| 14 | namespace OpenAI.Chat |
| 15 | { |
| 16 | public partial class ChatClient |
| 17 | { |
| 18 | private readonly Uri _endpoint; |
| 19 | |
| 20 | protected ChatClient() |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | public ClientPipeline Pipeline { get; } |
| 25 | |
| 26 | [Experimental("OPENAI001")] |
| 27 | public virtual CollectionResult GetChatCompletions(string after, int? limit, string order, IDictionary<string, string> metadata, string model, RequestOptions options) |
| 28 | { |
| 29 | return new ChatClientGetChatCompletionsCollectionResult( |
| 30 | this, |
| 31 | after, |
| 32 | limit, |
| 33 | order, |
| 34 | metadata, |
| 35 | model, |
| 36 | options); |
| 37 | } |
| 38 | |
| 39 | [Experimental("OPENAI001")] |
| 40 | public virtual AsyncCollectionResult GetChatCompletionsAsync(string after, int? limit, string order, IDictionary<string, string> metadata, string model, RequestOptions options) |
| 41 | { |
| 42 | return new ChatClientGetChatCompletionsAsyncCollectionResult( |
| 43 | this, |
| 44 | after, |
| 45 | limit, |
| 46 | order, |
| 47 | metadata, |
| 48 | model, |
| 49 | options); |
| 50 | } |
| 51 | |
| 52 | [Experimental("OPENAI001")] |
| 53 | public virtual CollectionResult<ChatCompletion> GetChatCompletions(ChatCompletionCollectionOptions options = default, CancellationToken cancellationToken = default) |
| 54 | { |
| 55 | return new ChatClientGetChatCompletionsCollectionResultOfT( |
| 56 | this, |
| 57 | options?.AfterId, |
| 58 | options?.PageSizeLimit, |
| 59 | options?.Order?.ToString(), |
| 60 | options?.Metadata, |
| 61 | options?.Model, |
| 62 | cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null); |
| 63 | } |
| 64 | |
| 65 | [Experimental("OPENAI001")] |
| 66 | public virtual AsyncCollectionResult<ChatCompletion> GetChatCompletionsAsync(ChatCompletionCollectionOptions options = default, CancellationToken cancellationToken = default) |
| 67 | { |
| 68 | return new ChatClientGetChatCompletionsAsyncCollectionResultOfT( |
| 69 | this, |
| 70 | options?.AfterId, |
| 71 | options?.PageSizeLimit, |
| 72 | options?.Order?.ToString(), |
| 73 | options?.Metadata, |
| 74 | options?.Model, |
| 75 | cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null); |
| 76 | } |
| 77 | |
| 78 | public virtual ClientResult CompleteChat(BinaryContent content, RequestOptions options = null) |
| 79 | { |
| 80 | Argument.AssertNotNull(content, nameof(content)); |
| 81 | |
| 82 | using PipelineMessage message = CreateCompleteChatRequest(content, options); |
| 83 | return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); |
| 84 | } |
| 85 | |
| 86 | public virtual async Task<ClientResult> CompleteChatAsync(BinaryContent content, RequestOptions options = null) |
| 87 | { |
| 88 | Argument.AssertNotNull(content, nameof(content)); |
| 89 | |
| 90 | using PipelineMessage message = CreateCompleteChatRequest(content, options); |
| 91 | return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); |
| 92 | } |
| 93 | } |
| 94 | } |