Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions OpenAI_API/Embedding/EmbeddingEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
50 changes: 34 additions & 16 deletions OpenAI_API/Embedding/EmbeddingRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{

}
Expand All @@ -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;
}
}
}
6 changes: 6 additions & 0 deletions OpenAI_API/Embedding/IEmbeddingEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down