openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.2.0-beta.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Embeddings/EmbeddingClient.Protocol.cs

54lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.ComponentModel;
5using System.Threading.Tasks;
6
7namespace OpenAI.Embeddings;
8
9[CodeGenSuppress("CreateEmbeddingAsync", typeof(BinaryContent), typeof(RequestOptions))]
10[CodeGenSuppress("CreateEmbedding", typeof(BinaryContent), typeof(RequestOptions))]
11public partial class EmbeddingClient
12{
13 // CUSTOM:
14 // - Renamed.
15 // - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
16 // - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
17 /// <summary>
18 /// [Protocol Method] Creates an embedding vector representing the input text.
19 /// </summary>
20 /// <param name="content"> The content to send as the body of the request. </param>
21 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
22 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
23 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
24 /// <returns> The response returned from the service. </returns>
25 [EditorBrowsable(EditorBrowsableState.Never)]
26 public virtual async Task<ClientResult> GenerateEmbeddingsAsync(BinaryContent content, RequestOptions options = null)
27 {
28 Argument.AssertNotNull(content, nameof(content));
29
30 using PipelineMessage message = CreateCreateEmbeddingRequest(content, options);
31 return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
32 }
33
34 // CUSTOM:
35 // - Renamed.
36 // - Edited the cref in the doc comment to point to the correct convenience overload after it was also renamed.
37 // - Added the EditorBrowsable attribute to hide protocol methods from IntelliSense when a convenience overload is available.
38 /// <summary>
39 /// [Protocol Method] Creates an embedding vector representing the input text.
40 /// </summary>
41 /// <param name="content"> The content to send as the body of the request. </param>
42 /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
43 /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
44 /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
45 /// <returns> The response returned from the service. </returns>
46 [EditorBrowsable(EditorBrowsableState.Never)]
47 public virtual ClientResult GenerateEmbeddings(BinaryContent content, RequestOptions options = null)
48 {
49 Argument.AssertNotNull(content, nameof(content));
50
51 using PipelineMessage message = CreateCreateEmbeddingRequest(content, options);
52 return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
53 }
54}