Skip to main content

module  pixeltable.functions.twelvelabs

Pixeltable UDFs that wrap various endpoints from the TwelveLabs API. In order to use them, you must first pip install twelvelabs and configure your TwelveLabs credentials, as described in the Working with TwelveLabs tutorial.

udf  embed()

Signature
embed(
    model_name: pxt.String,
    *,
    text: pxt.String | None = None,
    text_truncate: pxt.String | None = None,
    audio: pxt.Audio | None = None
) -> pxt.Array[(1024,), Float]
Creates an embedding vector for the given text, audio, or image parameter. Only one of text, audio, or image may be specified. Equivalent to the TwelveLabs Embed API. https://docs.twelvelabs.io/v1.3/docs/guides/create-embeddings Request throttling: Applies the rate limit set in the config (section twelvelabs, key rate_limit). If no rate limit is configured, uses a default of 600 RPM. Requirements:
  • pip install twelvelabs
Parameters:
  • model_name (pxt.String): The name of the model to use. Check the TwelveLabs documentation for available models.
  • text (pxt.String | None): The text to embed.
  • text_truncate (pxt.String | None): Truncation mode for the text.
  • audio (pxt.Audio | None): The audio to embed.
Returns:
  • pxt.Array[(1024,), Float]: The embedding.
Examples: Add a computed column embed for an embedding of a string column input:
tbl.add_computed_column(
    embed=embed(model_name='Marengo-retrieval-2.7', text=tbl.input)
)