Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docstrings langchain update #14869

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions libs/langchain/langchain/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,7 @@ async def aplan(
intermediate_steps: List[Tuple[AgentAction, str]],
callbacks: Callbacks = None,
**kwargs: Any,
) -> Union[
AgentAction,
AgentFinish,
]:
) -> Union[AgentAction, AgentFinish,]:
"""Given input, decided what to do.

Args:
Expand Down Expand Up @@ -442,10 +439,7 @@ def plan(
intermediate_steps: List[Tuple[AgentAction, str]],
callbacks: Callbacks = None,
**kwargs: Any,
) -> Union[
List[AgentAction],
AgentFinish,
]:
) -> Union[List[AgentAction], AgentFinish,]:
"""Given input, decided what to do.

Args:
Expand All @@ -466,10 +460,7 @@ async def aplan(
intermediate_steps: List[Tuple[AgentAction, str]],
callbacks: Callbacks = None,
**kwargs: Any,
) -> Union[
List[AgentAction],
AgentFinish,
]:
) -> Union[List[AgentAction], AgentFinish,]:
"""Given input, decided what to do.

Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 10 additions & 0 deletions libs/langchain/langchain/chains/openai_tools/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain/langchain/retrievers/self_query/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


class RedisTranslator(Visitor):
"""Translate"""
"""Visitor for translating structured queries to Redis filter expressions."""

allowed_comparators = (
Comparator.EQ,
Expand Down
2 changes: 2 additions & 0 deletions libs/langchain/langchain/smith/evaluation/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
3 changes: 2 additions & 1 deletion libs/langchain/langchain/text_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ def split_text(self, text: str) -> List[Document]:
if stripped_line.startswith(sep) and (
# Header with no text OR header is followed by space
# Both are valid conditions that sep is being used a header
len(stripped_line) == len(sep) or stripped_line[len(sep)] == " "
len(stripped_line) == len(sep)
or stripped_line[len(sep)] == " "
):
# Ensure we are tracking the header as metadata
if name is not None:
Expand Down
2 changes: 2 additions & 0 deletions libs/langchain/langchain/tools/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@


class RetrieverInput(BaseModel):
"""Input to the retriever."""

query: str = Field(description="query to look up in retriever")


Expand Down
Loading