Class EmbeddingModel
- Namespace
- GenerativeAI
- Assembly
- GenerativeAI.dll
Represents a machine learning model for generating embeddings from input text or content. This model allows handling of single or batch embedding operations using various input types or formats. Inherits from the BaseModel class.
public class EmbeddingModel : BaseModel
- Inheritance
-
EmbeddingModel
- Inherited Members
- Extension Methods
Constructors
EmbeddingModel(IPlatformAdapter, string, HttpClient?, ILogger?)
A class that represents an embedding model used for generating vector embeddings from input content such as text or files. This model supports both single and batch operations for processing multiple inputs and generates high-dimensional embeddings compatible with various downstream applications.
public EmbeddingModel(IPlatformAdapter platform, string model, HttpClient? httpClient = null, ILogger? logger = null)
Parameters
platformIPlatformAdaptermodelstringhttpClientHttpClientloggerILogger
Remarks
This class provides multiple overloads of the EmbedContentAsync method to handle different
input types, including strings, content objects, and batch requests. It is designed to be flexible
for integration with machine learning workflows.
EmbeddingModel(string, string, HttpClient?, ILogger?)
A class that represents an embedding model designed to generate vector representations (embeddings) from input text or content. Supports operations for both single inputs and batch processing using multiple input types.
public EmbeddingModel(string apiKey, string model, HttpClient? httpClient = null, ILogger? logger = null)
Parameters
apiKeystringmodelstringhttpClientHttpClientloggerILogger
Remarks
The class provides several overloads of the EmbedContentAsync method to allow flexibility in embedding
generation based on the input structure, such as individual strings, content objects, or collections.
It also supports batch operations through BatchEmbedContentAsync methods for efficiency in processing
multiple inputs simultaneously. This model integrates functionality inherited from the BaseModel class.
Properties
Model
Gets or sets the name or identifier of the embedding model to be used for generating embeddings. The model name typically represents a specific configuration or version of the machine learning model. This property is utilized in embedding operations to define which model to apply for processing the input.
public string Model { get; set; }
Property Value
Methods
BatchEmbedContentAsync(IEnumerable<Content>, CancellationToken)
Embeds a batch of content based on a collection of Content objects.
public Task<BatchEmbedContentsResponse> BatchEmbedContentAsync(IEnumerable<Content> contents, CancellationToken cancellationToken = default)
Parameters
contentsIEnumerable<Content>The collection of Content objects to embed.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<BatchEmbedContentsResponse>
A task representing the asynchronous operation, containing the batch embedding response.
BatchEmbedContentAsync(IEnumerable<EmbedContentRequest>, CancellationToken)
Embeds a batch of content based on a collection of Content objects.
public Task<BatchEmbedContentsResponse> BatchEmbedContentAsync(IEnumerable<EmbedContentRequest> requests, CancellationToken cancellationToken = default)
Parameters
requestsIEnumerable<EmbedContentRequest>The collection of EmbedContentRequest requests to embed.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<BatchEmbedContentsResponse>
A task representing the asynchronous operation, containing the batch embedding response.
EmbedContentAsync(Content, CancellationToken)
Embeds content based on a text input message.
public Task<EmbedContentResponse> EmbedContentAsync(Content content, CancellationToken cancellationToken = default)
Parameters
contentContentThe content object to generate embeddings from.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<EmbedContentResponse>
A task representing the asynchronous operation, containing the embedding response.
EmbedContentAsync(EmbedContentRequest, CancellationToken)
Embeds content based on the provided text input message.
public Task<EmbedContentResponse> EmbedContentAsync(EmbedContentRequest request, CancellationToken cancellationToken = default)
Parameters
requestEmbedContentRequestThe request object to generate embeddings from.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<EmbedContentResponse>
A task representing the asynchronous operation, containing the embedding response.
EmbedContentAsync(IEnumerable<Part>, CancellationToken)
Embeds content based on a sequence of Part objects.
public Task<EmbedContentResponse> EmbedContentAsync(IEnumerable<Part> parts, CancellationToken cancellationToken = default)
Parameters
partsIEnumerable<Part>The sequence of Part objects to be used for embedding content.
cancellationTokenCancellationTokenA token for cancelling the operation, if needed.
Returns
- Task<EmbedContentResponse>
Returns an instance of EmbedContentResponse containing the embeddings.
EmbedContentAsync(IEnumerable<string>, CancellationToken)
Embeds content based on a collection of strings.
public Task<EmbedContentResponse> EmbedContentAsync(IEnumerable<string> messages, CancellationToken cancellationToken = default)
Parameters
messagesIEnumerable<string>The collection of text strings to generate embeddings from.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<EmbedContentResponse>
A task representing the asynchronous operation, containing the embedding response.
EmbedContentAsync(string, CancellationToken)
Embeds content based on a text input message.
public Task<EmbedContentResponse> EmbedContentAsync(string message, CancellationToken cancellationToken = default)
Parameters
messagestringThe text input to generate embeddings from.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<EmbedContentResponse>
A task representing the asynchronous operation, containing the embedding response.