embedding • AI Agents Framework

embedding: Get embedding vector for text.

embedding

Function

</div>

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

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

Parameters

ParamField Any

Text string or list of strings to embed

ParamField Any

Embedding model name (default: text-embedding-3-small) **kwargs: Additional arguments passed to litellm.embedding()

Returns

ResponseField Any

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

Usage

python
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")

Uses

  • warn_deprecated_param
  • warnings.warn
  • ImportError
  • litellm.embedding

Notes

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

Used By

Source

View on GitHub

praisonai/llm/__init__.py at line 61