Files
mnote/wolai-backend/.venv312/Lib/site-packages/pgvector/asyncpg/register.py
T

32 lines
835 B
Python
Raw Normal View History

2025-12-08 19:56:24 +08:00
from ..utils import Vector, HalfVector, SparseVector
async def register_vector(conn, schema='public'):
await conn.set_type_codec(
'vector',
schema=schema,
encoder=Vector._to_db_binary,
decoder=Vector._from_db_binary,
format='binary'
)
try:
await conn.set_type_codec(
'halfvec',
schema=schema,
encoder=HalfVector._to_db_binary,
decoder=HalfVector._from_db_binary,
format='binary'
)
await conn.set_type_codec(
'sparsevec',
schema=schema,
encoder=SparseVector._to_db_binary,
decoder=SparseVector._from_db_binary,
format='binary'
)
except ValueError as e:
if not str(e).startswith('unknown type:'):
raise e