The Resources.Embed
class provides methods to create text embeddings.
Create text embeddings
Description: This method creates a new text embedding.
Function signature and example:
async create(
{ engineName, text, textTruncate }: CreateEmbedParams,
options: RequestOptions = {},
): Promise<Models.CreateEmbeddingsResult>
const embedding = await client.embed.create({
engineName: 'Marengo-retrieval-2.6',
textTruncate: 'start',
text: '<YOUR_TEXT>
});
console.log("Created a text embedding")
console.log(` Engine: ${embedding.engineName}`);
console.log(` Embedding: ${embedding.textEmbedding.float}`)
Parameters:
Name | Type | Required | Description |
---|---|---|---|
params | CreateEmbedParams | Yes | Parameters for creating the text embedding. |
options | RequestOptions | No | Additional options for the request. Defaults to {} . |
The CreateEmbedParams
interface defines the parameters for creating a text embedding.
Name | Type | Required | Description |
---|---|---|---|
engineName | string | Yes | The name of the video understanding engine to use. Example: "Marengo-retrieval-2.6". |
text | string | Yes | The text for which you want to create an embedding. |
textTruncate | 'none' | 'start' | 'end' | No | Specifies how to truncate the text if it exceeds the maximum length of 77 tokens. |
Return value: Returns a Promise
that resolves to a Models.CreateEmbeddingsResult
instance.
API Reference: For a description of each field in the request and response, see the Create text embeddings page.
Related guide: Create text embeddings.