Embedding 端口增加 is_available(),聊天和回忆录日志用统一方式表示向量是否真能调用。 记忆整理(compaction)支持 Beat 定期扫用户; 事实抽取提示与 subject 归一化,减少同一人多种称呼;
27 lines
879 B
Python
27 lines
879 B
Python
"""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 会话)。"""
|
||
...
|