Validates and normalizes embedding vectors, raising clear errors on invalid data.
# Source: https://github.com/HKUDS/DeepTutor | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Validation helpers for embedding vectors."""
from __future__ import annotations
from collections.abc import Sequence
import math
from numbers import Real
from typing import Any
def _context(
*,
binding: str | None,
model: str | None,
batch_index: int | None,
total_batches: int | None,
) -> str:
parts: list[str] = []
if binding:
parts.append(f"binding={binding}")
if model:
parts.append(f"model={model}")
if batch_index is not None and total_batches is not None:
parts.append(f"batch={batch_index}/{total_batches}")
return f"
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key