diff --git a/OpenAI_API/Embedding/EmbeddingEndpoint.cs b/OpenAI_API/Embedding/EmbeddingEndpoint.cs index a324de9..c0ea25b 100644 --- a/OpenAI_API/Embedding/EmbeddingEndpoint.cs +++ b/OpenAI_API/Embedding/EmbeddingEndpoint.cs @@ -35,12 +35,23 @@ public async Task<EmbeddingResult> CreateEmbeddingAsync(string input) return await CreateEmbeddingAsync(req); } - /// <summary> - /// Ask the API to embedd text using a custom request - /// </summary> - /// <param name="request">Request to be send</param> - /// <returns>Asynchronously returns the embedding result. Look in its <see cref="Data.Embedding"/> property of <see cref="EmbeddingResult.Data"/> to find the vector of floating point numbers</returns> - public async Task<EmbeddingResult> CreateEmbeddingAsync(EmbeddingRequest request) + /// <summary> + /// Ask the API to embedd text using the default embedding model <see cref="Model.AdaTextEmbedding"/> + /// </summary> + /// <param name="input">Text to be embedded</param> + /// <returns>Asynchronously returns the embedding resu + public async Task<EmbeddingResult> CreateEmbeddingAsync(string[] batchInput) + { + EmbeddingRequest req = new EmbeddingRequest(DefaultEmbeddingRequestArgs.Model, batchInput); + return await CreateEmbeddingAsync(req); + } + + /// <summary> + /// Ask the API to embedd text using a custom request + /// </summary> + /// <param name="request">Request to be send</param> + /// <returns>Asynchronously returns the embedding result. Look in its <see cref="Data.Embedding"/> property of <see cref="EmbeddingResult.Data"/> to find the vector of floating point numbers</returns> + public async Task<EmbeddingResult> CreateEmbeddingAsync(EmbeddingRequest request) { return await HttpPost<EmbeddingResult>(postData: request); } diff --git a/OpenAI_API/Embedding/EmbeddingRequest.cs b/OpenAI_API/Embedding/EmbeddingRequest.cs index 99780eb..16052fb 100644 --- a/OpenAI_API/Embedding/EmbeddingRequest.cs +++ b/OpenAI_API/Embedding/EmbeddingRequest.cs @@ -14,16 +14,16 @@ public class EmbeddingRequest [JsonProperty("model")] public string Model { get; set; } - /// <summary> - /// Main text to be embedded - /// </summary> - [JsonProperty("input")] - public string Input { get; set; } + /// <summary> + /// Main text to be embedded + /// </summary> + [JsonProperty("input")] + public object Input { get; set; } - /// <summary> - /// Cretes a new, empty <see cref="EmbeddingRequest"/> - /// </summary> - public EmbeddingRequest() + /// <summary> + /// Cretes a new, empty <see cref="EmbeddingRequest"/> + /// </summary> + public EmbeddingRequest() { } @@ -38,15 +38,33 @@ public EmbeddingRequest(Model model, string input) Model = model; this.Input = input; } - - /// <summary> - /// Creates a new <see cref="EmbeddingRequest"/> with the specified input and the <see cref="Model.AdaTextEmbedding"/> model. - /// </summary> - /// <param name="input">The prompt to transform</param> - public EmbeddingRequest(string input) + /// <summary> + /// Creates a new <see cref="EmbeddingRequest"/> with the specified parameters + /// </summary> + /// <param name="model">The model to use. You can use <see cref="ModelsEndpoint.GetModelsAsync()"/> to see all of your available models, or use a standard model like <see cref="Model.AdaTextEmbedding"/>.</param> + /// <param name="batchInput">The prompt to transform</param> + public EmbeddingRequest(Model model, string[] batchInput) + { + Model = model; + Input = batchInput; + } + /// <summary> + /// Creates a new <see cref="EmbeddingRequest"/> with the specified input and the <see cref="Model.AdaTextEmbedding"/> model. + /// </summary> + /// <param name="input">The prompt to transform</param> + public EmbeddingRequest(string input) { Model = OpenAI_API.Models.Model.AdaTextEmbedding; this.Input = input; } - } + /// <summary> + /// Creates a new <see cref="EmbeddingRequest"/> with the specified input and the <see cref="Model.AdaTextEmbedding"/> model. + /// </summary> + /// <param name="batchInput">The prompt to transform</param> + public EmbeddingRequest(string[] batchInput) + { + Model = OpenAI_API.Models.Model.AdaTextEmbedding; + Input = batchInput; + } + } } diff --git a/OpenAI_API/Embedding/IEmbeddingEndpoint.cs b/OpenAI_API/Embedding/IEmbeddingEndpoint.cs index acd9069..08c9d54 100644 --- a/OpenAI_API/Embedding/IEmbeddingEndpoint.cs +++ b/OpenAI_API/Embedding/IEmbeddingEndpoint.cs @@ -20,6 +20,12 @@ public interface IEmbeddingEndpoint /// <returns>Asynchronously returns the embedding result. Look in its <see cref="Data.Embedding"/> property of <see cref="EmbeddingResult.Data"/> to find the vector of floating point numbers</returns> Task<EmbeddingResult> CreateEmbeddingAsync(string input); + /// <summary> + /// Ask the API to embedd text using the default embedding model <see cref="Model.AdaTextEmbedding"/> + /// </summary> + /// <param name="batchInput">Text to be embedded</param> + /// <returns>Asynchronously returns the embedding result. Look in its <see cref="Data.Embedding"/> property of <see cref="EmbeddingResult.Data"/> to find the vector of floating point numbers</returns> + Task<EmbeddingResult> CreateEmbeddingAsync(string[] batchInput); /// <summary> /// Ask the API to embedd text using a custom request /// </summary>