docstrings langchain update (#14870)

Added missed docstrings
This commit is contained in:
Leonid Ganeline 2023-12-18 17:16:08 -08:00 committed by GitHub
parent ea331f3136
commit 6577b0d987
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 1 deletions

View File

@ -55,8 +55,12 @@ def _get_chat_history(chat_history: List[CHAT_TURN_TYPE]) -> str:
class InputType(BaseModel): class InputType(BaseModel):
"""Input type for ConversationalRetrievalChain."""
question: str question: str
"""The question to answer."""
chat_history: List[CHAT_TURN_TYPE] = Field(default_factory=list) chat_history: List[CHAT_TURN_TYPE] = Field(default_factory=list)
"""The chat history to use for retrieval."""
class BaseConversationalRetrievalChain(Chain): class BaseConversationalRetrievalChain(Chain):

View File

@ -19,6 +19,16 @@ def create_extraction_chain_pydantic(
llm: BaseLanguageModel, llm: BaseLanguageModel,
system_message: str = _EXTRACTION_TEMPLATE, system_message: str = _EXTRACTION_TEMPLATE,
) -> Runnable: ) -> 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): if not isinstance(pydantic_schemas, list):
pydantic_schemas = [pydantic_schemas] pydantic_schemas = [pydantic_schemas]
prompt = ChatPromptTemplate.from_messages( prompt = ChatPromptTemplate.from_messages(

View File

@ -34,7 +34,7 @@ _COMPARATOR_TO_BUILTIN_METHOD = {
class RedisTranslator(Visitor): class RedisTranslator(Visitor):
"""Translate""" """Visitor for translating structured queries to Redis filter expressions."""
allowed_comparators = ( allowed_comparators = (
Comparator.EQ, Comparator.EQ,

View File

@ -55,6 +55,8 @@ class EvalConfig(BaseModel):
class SingleKeyEvalConfig(EvalConfig): class SingleKeyEvalConfig(EvalConfig):
"""Configuration for a run evaluator that only requires a single key."""
reference_key: Optional[str] = None reference_key: Optional[str] = None
"""The key in the dataset run to use as the reference string. """The key in the dataset run to use as the reference string.
If not provided, we will attempt to infer automatically.""" If not provided, we will attempt to infer automatically."""

View File

@ -5,6 +5,8 @@ from langchain.tools import Tool
class RetrieverInput(BaseModel): class RetrieverInput(BaseModel):
"""Input to the retriever."""
query: str = Field(description="query to look up in retriever") query: str = Field(description="query to look up in retriever")