protocol.py
1 from __future__ import annotations 2 3 """Protocol for embedding model implementations.""" 4 5 from typing import Protocol 6 7 8 class Embeddings(Protocol): 9 """Protocol for embedding model implementations. 10 11 Compatible with LangChain's Embeddings interface and any custom 12 implementation that provides these methods. 13 """ 14 15 def embed_documents(self, texts: list[str]) -> list[list[float]]: 16 """Embed a list of documents.""" 17 ... 18 19 def embed_query(self, text: str) -> list[float]: 20 """Embed a single query text.""" 21 ... 22