"""应用层 Protocol 端口定义。""" from __future__ import annotations from typing import TYPE_CHECKING, Protocol, runtime_checkable if TYPE_CHECKING: import numpy as np @runtime_checkable class EmbeddingProvider(Protocol): """文本嵌入端口。 属性: dim: 嵌入维度 D。 """ @property def dim(self) -> int: ... def embed(self, texts: str | list[str]) -> np.ndarray: """文本 → 嵌入向量(L2 归一化)。 参数: texts: 单条文本或文本列表。 返回: [N, D] ndarray,每行 L2 范数为 1.0。 """ ...