mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 07:35:18 +00:00
core: docstrings documents
(#23506)
Added missed docstrings. Formatted docstrings to the consistent form.
This commit is contained in:
parent
77dd327282
commit
5fcf2ef7ca
@ -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
|
||||
)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user