Files
life-echo/api/app/ports/embedding.py
Kevin 41518bda11 聊天和回忆录证据检索都走 pgvector,去掉 Postgres FTS/content_tsv,新迁移删掉 content_tsv 列(部署要先 alembic upgrade)。
Embedding 端口增加 is_available(),聊天和回忆录日志用统一方式表示向量是否真能调用。

记忆整理(compaction)支持 Beat 定期扫用户;

事实抽取提示与 subject 归一化,减少同一人多种称呼;
2026-04-03 11:43:16 +08:00

27 lines
879 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""EmbeddingProvider port — 文本向量化能力契约。"""
from typing import Protocol, runtime_checkable
@runtime_checkable
class EmbeddingProvider(Protocol):
def is_available(self) -> bool:
"""进程内 embedding 已配置且可发起调用(无 key / 未初始化 client 时为 False"""
...
async def embed_text(self, text: str) -> list[float]:
"""Embed a single text into a vector."""
...
async def embed_texts(self, texts: list[str]) -> list[list[float]]:
"""Embed multiple texts into vectors."""
...
def embed_text_sync(self, text: str) -> list[float]:
"""同步嵌入单条文本Celery / sync DB 会话)。"""
...
def embed_texts_sync(self, texts: list[str]) -> list[list[float]]:
"""同步嵌入多条文本Celery / sync DB 会话)。"""
...