diff --git a/libs/core/langchain_core/documents/compressor.py b/libs/core/langchain_core/documents/compressor.py index 6ed597a1e5d..895079fc127 100644 --- a/libs/core/langchain_core/documents/compressor.py +++ b/libs/core/langchain_core/documents/compressor.py @@ -32,7 +32,16 @@ class BaseDocumentCompressor(BaseModel, ABC): query: str, callbacks: Optional[Callbacks] = None, ) -> Sequence[Document]: - """Compress retrieved documents given the query context.""" + """Compress retrieved documents given the query context. + + Args: + documents: The retrieved documents. + query: The query context. + callbacks: Optional callbacks to run during compression. + + Returns: + The compressed documents. + """ async def acompress_documents( self, @@ -40,7 +49,16 @@ class BaseDocumentCompressor(BaseModel, ABC): query: str, callbacks: Optional[Callbacks] = None, ) -> Sequence[Document]: - """Compress retrieved documents given the query context.""" + """Async compress retrieved documents given the query context. + + Args: + documents: The retrieved documents. + query: The query context. + callbacks: Optional callbacks to run during compression. + + Returns: + The compressed documents. + """ return await run_in_executor( None, self.compress_documents, documents, query, callbacks ) diff --git a/libs/core/langchain_core/documents/transformers.py b/libs/core/langchain_core/documents/transformers.py index 245e6a715c2..a11e20f4e50 100644 --- a/libs/core/langchain_core/documents/transformers.py +++ b/libs/core/langchain_core/documents/transformers.py @@ -10,9 +10,9 @@ if TYPE_CHECKING: class BaseDocumentTransformer(ABC): - """Abstract base class for document transformation systems. + """Abstract base class for document transformation. - A document transformation system takes a sequence of Documents and returns a + A document transformation takes a sequence of Documents and returns a sequence of transformed Documents. Example: @@ -55,7 +55,7 @@ class BaseDocumentTransformer(ABC): documents: A sequence of Documents to be transformed. Returns: - A list of transformed Documents. + A sequence of transformed Documents. """ async def atransform_documents( @@ -67,7 +67,7 @@ class BaseDocumentTransformer(ABC): documents: A sequence of Documents to be transformed. Returns: - A list of transformed Documents. + A sequence of transformed Documents. """ return await run_in_executor( None, self.transform_documents, documents, **kwargs diff --git a/libs/core/langchain_core/embeddings/embeddings.py b/libs/core/langchain_core/embeddings/embeddings.py index f10818ecfdc..f2b0e83f80a 100644 --- a/libs/core/langchain_core/embeddings/embeddings.py +++ b/libs/core/langchain_core/embeddings/embeddings.py @@ -7,7 +7,7 @@ from langchain_core.runnables.config import run_in_executor class Embeddings(ABC): - """An interface for embedding models. + """Interface for embedding models. This is an interface meant for implementing text embedding models. @@ -36,16 +36,44 @@ class Embeddings(ABC): @abstractmethod def embed_documents(self, texts: List[str]) -> List[List[float]]: - """Embed search docs.""" + """Embed search docs. + + Args: + texts: List of text to embed. + + Returns: + List of embeddings. + """ @abstractmethod def embed_query(self, text: str) -> List[float]: - """Embed query text.""" + """Embed query text. + + Args: + text: Text to embed. + + Returns: + Embedding. + """ async def aembed_documents(self, texts: List[str]) -> List[List[float]]: - """Asynchronous Embed search docs.""" + """Asynchronous Embed search docs. + + Args: + texts: List of text to embed. + + Returns: + List of embeddings. + """ return await run_in_executor(None, self.embed_documents, texts) async def aembed_query(self, text: str) -> List[float]: - """Asynchronous Embed query text.""" + """Asynchronous Embed query text. + + Args: + text: Text to embed. + + Returns: + Embedding. + """ return await run_in_executor(None, self.embed_query, text)