Method GenerateAsync
- Namespace
- MailFathom.AI.Embeddings
- Assembly
- MailFathom.AI.dll
GenerateAsync(IReadOnlyList<string>, CancellationToken)
Produces one vector for each passage, in the order the passages were given.
public Task<IReadOnlyList<EmbeddingVector>> GenerateAsync(IReadOnlyList<string> passages, CancellationToken cancellationToken)
Parameters
passagesIReadOnlyList<string>The passages to embed, at most MaximumPassagesPerCall of them and none of them blank.
cancellationTokenCancellationTokenCancels the call and every remaining attempt of it.
Returns
- Task<IReadOnlyList<EmbeddingVector>>
One vector per passage, in the same order, each of Dimension components.
Remarks
The call is free of side effects and safe to repeat: nothing is written, and a passage embedded twice produces the same vector for every model this system supports. Preparing a passage — cutting it to what the model accepts and prefixing whatever the model requires — belongs to the implementation, because those choices are part of Identity and a caller that made them would be able to disagree with it.
Exceptions
- ArgumentNullException
Thrown when
passagesis null.- ArgumentException
Thrown when the sequence is empty, holds a blank passage, or holds more passages than one call accepts.
- EmbeddingGenerationFailedException
Thrown when the request reached a provider and produced no vectors. Its Failure says which kind of failure ended it.
- OperationCanceledException
Thrown when the caller cancelled or the host is shutting down. Never reported as a provider failure, because neither is one.