openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.1.0-beta.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Chat/ChatClient.Protocol.cs

47lines · modeblame

58f93c8dShivangiReja2 years ago1using System;
9f9f2936Jose Arriaga Maldonado2 years ago2using 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)]
23public virtual async Task<ClientResult> CompleteChatAsync(BinaryContent content, RequestOptions options = null)
24{
25Argument.AssertNotNull(content, nameof(content));
26
27using PipelineMessage message = CreateCreateChatCompletionRequest(content, options);
28return 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)]
40public virtual ClientResult CompleteChat(BinaryContent content, RequestOptions options = null)
41{
42Argument.AssertNotNull(content, nameof(content));
43
44using PipelineMessage message = CreateCreateChatCompletionRequest(content, options);
45return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options));
46}
47}