From ff17da32b1bfd3b6b0e39c1241cafa0f463350f8 Mon Sep 17 00:00:00 2001 From: leo-gan Date: Mon, 18 Dec 2023 14:49:29 -0800 Subject: [PATCH] added docstrings --- .../langchain/chains/conversational_retrieval/base.py | 4 ++++ .../langchain/chains/openai_tools/extraction.py | 10 ++++++++++ .../langchain/langchain/retrievers/self_query/redis.py | 2 +- libs/langchain/langchain/smith/evaluation/config.py | 2 ++ libs/langchain/langchain/tools/retriever.py | 2 ++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain/chains/conversational_retrieval/base.py b/libs/langchain/langchain/chains/conversational_retrieval/base.py index dbe28df9b2783..0b15f4e41c9a9 100644 --- a/libs/langchain/langchain/chains/conversational_retrieval/base.py +++ b/libs/langchain/langchain/chains/conversational_retrieval/base.py @@ -55,8 +55,12 @@ def _get_chat_history(chat_history: List[CHAT_TURN_TYPE]) -> str: class InputType(BaseModel): + """Input type for ConversationalRetrievalChain.""" + question: str + """The question to answer.""" chat_history: List[CHAT_TURN_TYPE] = Field(default_factory=list) + """The chat history to use for retrieval.""" class BaseConversationalRetrievalChain(Chain): diff --git a/libs/langchain/langchain/chains/openai_tools/extraction.py b/libs/langchain/langchain/chains/openai_tools/extraction.py index a644d5768c5cf..6e7ebe65a07cc 100644 --- a/libs/langchain/langchain/chains/openai_tools/extraction.py +++ b/libs/langchain/langchain/chains/openai_tools/extraction.py @@ -19,6 +19,16 @@ def create_extraction_chain_pydantic( llm: BaseLanguageModel, system_message: str = _EXTRACTION_TEMPLATE, ) -> Runnable: + """Creates a chain that extracts information from a passage. + + Args: + pydantic_schemas: The schema of the entities to extract. + llm: The language model to use. + system_message: The system message to use for extraction. + + Returns: + A runnable that extracts information from a passage. + """ if not isinstance(pydantic_schemas, list): pydantic_schemas = [pydantic_schemas] prompt = ChatPromptTemplate.from_messages( diff --git a/libs/langchain/langchain/retrievers/self_query/redis.py b/libs/langchain/langchain/retrievers/self_query/redis.py index 963b58aa688e3..a13eb73407c60 100644 --- a/libs/langchain/langchain/retrievers/self_query/redis.py +++ b/libs/langchain/langchain/retrievers/self_query/redis.py @@ -34,7 +34,7 @@ class RedisTranslator(Visitor): - """Translate""" + """Visitor for translating structured queries to Redis filter expressions.""" allowed_comparators = ( Comparator.EQ, diff --git a/libs/langchain/langchain/smith/evaluation/config.py b/libs/langchain/langchain/smith/evaluation/config.py index 4db1f0c512b83..cbdd790e22861 100644 --- a/libs/langchain/langchain/smith/evaluation/config.py +++ b/libs/langchain/langchain/smith/evaluation/config.py @@ -55,6 +55,8 @@ def get_kwargs(self) -> Dict[str, Any]: class SingleKeyEvalConfig(EvalConfig): + """Configuration for a run evaluator that only requires a single key.""" + reference_key: Optional[str] = None """The key in the dataset run to use as the reference string. If not provided, we will attempt to infer automatically.""" diff --git a/libs/langchain/langchain/tools/retriever.py b/libs/langchain/langchain/tools/retriever.py index 1f613cf44fab6..a4ed55e96b9b4 100644 --- a/libs/langchain/langchain/tools/retriever.py +++ b/libs/langchain/langchain/tools/retriever.py @@ -5,6 +5,8 @@ class RetrieverInput(BaseModel): + """Input to the retriever.""" + query: str = Field(description="query to look up in retriever")