File size: 348 Bytes
44436be
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
from __future__ import annotations


def to_pgvector_literal(embedding: list[float]) -> str:
    """Formats a Python float list as a pgvector text literal, e.g. '[0.1,0.2]',
    for use with an explicit ::vector cast in raw SQL (no pgvector client
    library needed for this)."""
    return "[" + ",".join(str(value) for value in embedding) + "]"