openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.0.0-beta.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Chat/ChatClient.Protocol.cs

47lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.ComponentModel;
5using System.Threading.Tasks;
6
7namespace OpenAI.Chat;
8
9/// <summary> The service client for the OpenAI Chat Completions endpoint. </summary>
10[CodeGenSuppress("CreateChatCompletionAsync", typeof(BinaryContent), typeof(RequestOptions))]
11[CodeGenSuppress("CreateChatCompletion", typeof(BinaryContent), typeof(RequestOptions))]
12public partial class ChatClient
13{
14 /// <summary>
15 /// [Protocol Method] Creates a model response for the given chat conversation.
16 /// </summary>
17 /// <param name="content"> The content to send as the body of the request. </param>
18 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
19 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
20 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
21 /// <returns> The response returned from the service. </returns>
22 [EditorBrowsable(EditorBrowsableState.Never)]
23 public virtual async Task<ClientResult> CompleteChatAsync(BinaryContent content, RequestOptions options = null)
24 {
25 Argument.AssertNotNull(content, nameof(content));
26
27 using PipelineMessage message = CreateCreateChatCompletionRequest(content, options);
28 return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
29 }
30
31 /// <summary>
32 /// [Protocol Method] Creates a model response for the given chat conversation.
33 /// </summary>
34 /// <param name="content"> The content to send as the body of the request. </param>
35 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
36 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
37 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
38 /// <returns> The response returned from the service. </returns>
39 [EditorBrowsable(EditorBrowsableState.Never)]
40 public virtual ClientResult CompleteChat(BinaryContent content, RequestOptions options = null)
41 {
42 Argument.AssertNotNull(content, nameof(content));
43
44 using PipelineMessage message = CreateCreateChatCompletionRequest(content, options);
45 return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options));
46 }
47}
48