Skip to content

PerplexityEmbeddingModel

Namespace: Vercel.AI.Perplexity

public sealed class PerplexityEmbeddingModel : IEmbeddingModel, IEmbeddingCaller

Perplexity embeddings at {base}/v1/embeddings. Perplexity returns quantized vectors as base64, so the model decodes base64_int8 (the default) or base64_binary into numbers.

Inheritance: object

Implements: IEmbeddingModel, IEmbeddingCaller

View source

PerplexityEmbeddingModel(PerplexityProvider, string)

Section titled “PerplexityEmbeddingModel(PerplexityProvider, string)”
public PerplexityEmbeddingModel(PerplexityProvider provider, string modelId)

Creates an embedding model.

Parameters

Name Type Description
provider PerplexityProvider
modelId string

View source

public const int MaxValuesPerCall = 512

Maximum values per call.

Value: int

View source

public int? MaxEmbeddingsPerCall { get; }

Maximum values per call. Null means unlimited.

Value: int?

View source

public double? MaxInputBytesPerCall { get; }

Maximum UTF-8 input bytes per call. Null and infinity mean unlimited.

Value: double?

View source

public string ModelId { get; }

Model id.

Value: string

View source

public string Provider { get; }

Provider id.

Value: string

View source

public string SpecificationVersion { get; }

Specification version. Always V4.

Value: string

View source

public bool SupportsParallelCalls { get; }

Whether chunks may run at the same time.

Value: bool

View source

DoEmbedAsync(IReadOnlyList<string>, IReadOnlyDictionary<string, JsonElement>?, CancellationToken, int?, IReadOnlyDictionary<string, string?>?)

Section titled “DoEmbedAsync(IReadOnlyList<string>, IReadOnlyDictionary<string, JsonElement>?, CancellationToken, int?, IReadOnlyDictionary<string, string?>?)”
public Task<EmbeddingResult> DoEmbedAsync(IReadOnlyList<string> values, IReadOnlyDictionary<string, JsonElement>? providerOptions, CancellationToken cancellationToken, int? dimensions = null, IReadOnlyDictionary<string, string?>? headers = null)

Embeds each value. Maps to doEmbed. <code class=“paramref”>providerOptions</code> is keyed by provider id. <code class=“paramref”>dimensions</code> is the requested vector width. A provider option for the same setting wins. <code class=“paramref”>headers</code> are sent with this call and override the provider headers.

Parameters

Name Type Description
values IReadOnlyList<string>
providerOptions IReadOnlyDictionary<string, JsonElement>
cancellationToken CancellationToken
dimensions int?
headers IReadOnlyDictionary<string, string>

Returns: Task<EmbeddingResult>

View source

DoEmbedAsync(EmbeddingModelCall, CancellationToken)

Section titled “DoEmbedAsync(EmbeddingModelCall, CancellationToken)”
public Task<EmbeddingModelResponse> DoEmbedAsync(EmbeddingModelCall call, CancellationToken cancellationToken)

Embeds one chunk.

Parameters

Name Type Description
call EmbeddingModelCall
cancellationToken CancellationToken

Returns: Task<EmbeddingModelResponse>

View source

TransformProviderOptionsAsync(JsonElement?, IReadOnlyList<string>, int, int, CancellationToken)

Section titled “TransformProviderOptionsAsync(JsonElement?, IReadOnlyList<string>, int, int, CancellationToken)”
public Task<JsonElement?> TransformProviderOptionsAsync(JsonElement? providerOptions, IReadOnlyList<string> values, int startIndex, int endIndex, CancellationToken cancellationToken)

Slices provider options for one chunk. Null leaves the options unchanged.

Parameters

Name Type Description
providerOptions JsonElement?
values IReadOnlyList<string>
startIndex int
endIndex int
cancellationToken CancellationToken

Returns: Task<JsonElement?>

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product