Skip to main content

embedding

Function
This function is defined in the llm module.
Get embedding vector for text. .. deprecated:: Use from praisonai import embed or from praisonai.capabilities import embed instead. This function returns raw vectors; the new embed() returns EmbeddingResult with metadata.

Signature

def embedding(text: Any, model: Any) -> Any

Parameters

text
Any
required
Text string or list of strings to embed
model
Any
default:"'text-embedding-3-small'"
Embedding model name (default: text-embedding-3-small) **kwargs: Additional arguments passed to litellm.embedding()

Returns

Returns
Any
List[float] for single text, or List[List[float]] for multiple texts

Usage

from praisonai.llm import embedding

    # Single text
    emb = embedding("Hello world")

    # Multiple texts
    embs = embedding(["Hello", "World"])

    # Different model
    emb = embedding("Hello", model="text-embedding-3-large")

Note:
    Requires litellm. Install with: pip install praisonai[llm]