Embedding API
All the following functions, types, interfaces are exported by the library.
embed function
Converts text into numerical vectors
Signature:
function embed(options: EmbedOptions): Promise<Result<{
embeddings: Array<Embedding>;
}, RequestError>>;
Parameters
Parameter | Type |
---|---|
options | EmbeddingOptions |
Returns:
Promise<Result<{ embeddings: Array<[Embedding](#embedding)<!-- -->>; }
, RequestError>>
EmbeddingOptions
Options for embedding request
Signature:
interface EmbeddingOptions
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
content | Array<string> | The strings to embed, the returned embedding will correspond to the order of the passed string | |
extraParams? | Record<string, unknown> | (Optional) Allows extra model specific parameters. Consult with the documentation | |
model | EmbeddingModel | The model to embed with |
Embedding
Embedding vector returned by an embedding request
Signature:
interface Embedding
Properties
Property | Type | Description |
---|---|---|
truncated | boolean | Indicates if the input text was longer than max allowed tokens and truncated |
values | Array<number> | The embedding vectors corresponding to the words in the input text |
EmbeddingModel
Available models for text embedding
Signature:
type EmbeddingModel = 'textembedding-gecko';