Table of Contents

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

platform IPlatformAdapter
model string
httpClient HttpClient
logger ILogger

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

apiKey string
model string
httpClient HttpClient
logger ILogger

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

string

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

contents IEnumerable<Content>

The collection of Content objects to embed.

cancellationToken CancellationToken

A 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

requests IEnumerable<EmbedContentRequest>

The collection of EmbedContentRequest requests to embed.

cancellationToken CancellationToken

A 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

content Content

The content object to generate embeddings from.

cancellationToken CancellationToken

A 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

request EmbedContentRequest

The request object to generate embeddings from.

cancellationToken CancellationToken

A 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

parts IEnumerable<Part>

The sequence of Part objects to be used for embedding content.

cancellationToken CancellationToken

A 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

messages IEnumerable<string>

The collection of text strings to generate embeddings from.

cancellationToken CancellationToken

A 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

message string

The text input to generate embeddings from.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<EmbedContentResponse>

A task representing the asynchronous operation, containing the embedding response.