Get Dimensions • AI Agent SDK

get_dimensions: Get embedding dimensions based on model name.

get_dimensions

Function

</div>

This function is defined in the dimensions module.

Get embedding dimensions based on model name.

This function checks if the model name contains any known model identifiers and returns the corresponding dimension. Falls back to the default dimension (1536) for unknown models.

Signature

python
def get_dimensions(model_name: str) -> int

Parameters

ParamField str

The embedding model name (e.g., “text-embedding-3-small”)

Returns

ResponseField int

The embedding dimension for the model

Usage

python
>>> get_dimensions("text-embedding-3-small")
    1536
    >>> get_dimensions("openai/text-embedding-3-large")
    3072
    >>> get_dimensions("ollama/nomic-embed-text:v1.5")
    768
    >>> get_dimensions("unknown-model")
    1536

Uses

  • model_lower.rsplit

Source

View on GitHub

praisonaiagents/embedding/dimensions.py at line 75