PerplexityEmbeddingModel
Namespace: Vercel.AI.Perplexity
public sealed class PerplexityEmbeddingModel : IEmbeddingModel, IEmbeddingCallerPerplexity 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
Constructors
Section titled “Constructors”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 |
Fields
Section titled “Fields”MaxValuesPerCall
Section titled “MaxValuesPerCall”public const int MaxValuesPerCall = 512Maximum values per call.
Value: int
Properties
Section titled “Properties”MaxEmbeddingsPerCall
Section titled “MaxEmbeddingsPerCall”public int? MaxEmbeddingsPerCall { get; }Maximum values per call. Null means unlimited.
Value: int?
MaxInputBytesPerCall
Section titled “MaxInputBytesPerCall”public double? MaxInputBytesPerCall { get; }Maximum UTF-8 input bytes per call. Null and infinity mean unlimited.
Value: double?
ModelId
Section titled “ModelId”public string ModelId { get; }Model id.
Value: string
Provider
Section titled “Provider”public string Provider { get; }Provider id.
Value: string
SpecificationVersion
Section titled “SpecificationVersion”public string SpecificationVersion { get; }Specification version. Always V4.
Value: string
SupportsParallelCalls
Section titled “SupportsParallelCalls”public bool SupportsParallelCalls { get; }Whether chunks may run at the same time.
Value: bool
Methods
Section titled “Methods”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>
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>
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?>
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product