Skip to content

Commit 5b4c13b

Browse files
authored
Add an internal RequestOptions-based overload for GenerateEmbeddingsAsync (#704)
1 parent 96999b7 commit 5b4c13b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Custom/Embeddings/EmbeddingClient.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,20 @@ public virtual ClientResult<OpenAIEmbedding> GenerateEmbedding(string input, Emb
170170
/// <param name="cancellationToken"> A token that can be used to cancel this method call. </param>
171171
/// <exception cref="ArgumentNullException"> <paramref name="inputs"/> is null. </exception>
172172
/// <exception cref="ArgumentException"> <paramref name="inputs"/> is an empty collection, and was expected to be non-empty. </exception>
173-
public virtual async Task<ClientResult<OpenAIEmbeddingCollection>> GenerateEmbeddingsAsync(IEnumerable<string> inputs, EmbeddingGenerationOptions options = null, CancellationToken cancellationToken = default)
173+
public virtual Task<ClientResult<OpenAIEmbeddingCollection>> GenerateEmbeddingsAsync(IEnumerable<string> inputs, EmbeddingGenerationOptions options = null, CancellationToken cancellationToken = default)
174+
{
175+
return GenerateEmbeddingsAsync(inputs, options, cancellationToken.ToRequestOptions());
176+
}
177+
178+
internal async Task<ClientResult<OpenAIEmbeddingCollection>> GenerateEmbeddingsAsync(IEnumerable<string> inputs, EmbeddingGenerationOptions options, RequestOptions requestOptions)
174179
{
175180
Argument.AssertNotNullOrEmpty(inputs, nameof(inputs));
176181

177182
options ??= new();
178183
CreateEmbeddingGenerationOptions(inputs, ref options);
179184

180185
using BinaryContent content = options.ToBinaryContent();
181-
ClientResult result = await GenerateEmbeddingsAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
186+
ClientResult result = await GenerateEmbeddingsAsync(content, requestOptions).ConfigureAwait(false);
182187
return ClientResult.FromValue((OpenAIEmbeddingCollection)result, result.GetRawResponse());
183188

184189
}

0 commit comments

Comments
 (0)