mem0ai/mem0 · error · ValueError

Unsupported distance metric: {metric}

Error message

Unsupported distance metric: {metric}

What it means

Error "Unsupported distance metric: {metric}" thrown in mem0ai/mem0.

Source

Thrown at mem0/vector_stores/oracledb.py:61

            "and array wildcards '[*]' are allowed."
        )


_SCORE_FROM_DISTANCE = {
    "COSINE": lambda d: max(0.0, min(1.0, 1.0 - d)),
    "EUCLIDEAN": lambda d: 1.0 / (1.0 + max(0.0, d)),
    "EUCLIDEAN_SQUARED": lambda d: 1.0 / (1.0 + math.sqrt(max(0.0, d))),
    "HAMMING": lambda d: 1.0 / (1.0 + max(0.0, d)),
    "MANHATTAN": lambda d: 1.0 / (1.0 + max(0.0, d)),
    "DOT": lambda d: -d,
}


def _convert_distance_to_score(distance: float, metric: str) -> float:
    try:
        return _SCORE_FROM_DISTANCE[metric.upper()](distance)
    except KeyError:
        raise ValueError(f"Unsupported distance metric: {metric}") from None


_FIELD_OPERATORS = {"eq", "ne", "gt", "gte", "lt", "lte", "in", "nin", "contains", "icontains"}
_COMPARISON_OPERATORS = {
    "eq": "==",
    "ne": "!=",
    "gt": ">",
    "gte": ">=",
    "lt": "<",
    "lte": "<=",
}
_LOGICAL_OPERATORS = {
    "$and": "and",
    "$or": "or",
    "$not": "not",
    "AND": "and",
    "OR": "or",
    "NOT": "not",

View on GitHub (pinned to 001c235229)

Solutions

  1. Use a supported distance metric (e.g. COSINE, EUCLIDEAN_DISTANCE, DOT_PRODUCT).

When it happens

Trigger: Thrown at mem0/vector_stores/oracledb.py:61 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/fed4be83e467724b. Report an issue: GitHub.