The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
experimental[patch]: update module doc strings (#19539)
Leonid Ganeline4159a4723c0a
diff --git a/libs/experimental/langchain_experimental/agents/__init__.py b/libs/experimental/langchain_experimental/agents/__init__.pyindex 57affee471..fc1e4ef897 100644--- a/libs/experimental/langchain_experimental/agents/__init__.py+++ b/libs/experimental/langchain_experimental/agents/__init__.py@@ -1,3 +1,12 @@+"""**Agent** is a class that uses an LLM to choose+a sequence of actions to take.++In Chains, a sequence of actions is hardcoded. In Agents,+a language model is used as a reasoning engine to determine which actions+to take and in which order.++Agents select and use **Tools** and **Toolkits** for actions.+""" # noqa: E501from langchain_experimental.agents.agent_toolkits import (create_csv_agent,create_pandas_dataframe_agent,diff --git a/libs/experimental/langchain_experimental/autonomous_agents/__init__.py b/libs/experimental/langchain_experimental/autonomous_agents/__init__.pyindex 080a6d5a99..15ce2cb68d 100644--- a/libs/experimental/langchain_experimental/autonomous_agents/__init__.py+++ b/libs/experimental/langchain_experimental/autonomous_agents/__init__.py@@ -1,3 +1,15 @@+"""**Autonomous agents** in the Langchain experimental package include+[AutoGPT](https://github.com/Significant-Gravitas/AutoGPT),+[BabyAGI](https://github.com/yoheinakajima/babyagi),+and [HuggingGPT](https://arxiv.org/abs/2303.17580) agents that+interact with language models autonomously.++These agents have specific functionalities like memory management,+task creation, execution chains, and response generation.++They differ from ordinary agents by their autonomous decision-making capabilities,+memory handling, and specialized functionalities for tasks and response.+"""from langchain_experimental.autonomous_agents.autogpt.agent import AutoGPTfrom langchain_experimental.autonomous_agents.baby_agi.baby_agi import BabyAGIfrom langchain_experimental.autonomous_agents.hugginggpt.hugginggpt import HuggingGPTdiff --git a/libs/experimental/langchain_experimental/comprehend_moderation/__init__.py b/libs/experimental/langchain_experimental/comprehend_moderation/__init__.pyindex 4a265438f1..a8193b083f 100644--- a/libs/experimental/langchain_experimental/comprehend_moderation/__init__.py+++ b/libs/experimental/langchain_experimental/comprehend_moderation/__init__.py@@ -1,3 +1,23 @@+"""+**Comprehend Moderation** is used to detect and handle `Personally Identifiable Information (PII)`,+`toxicity`, and `prompt safety` in text.++The Langchain experimental package includes the **AmazonComprehendModerationChain** class+for the comprehend moderation tasks. It is based on `Amazon Comprehend` service.+This class can be configured with specific moderation settings like PII labels, redaction,+toxicity thresholds, and prompt safety thresholds.++See more at https://aws.amazon.com/comprehend/++`Amazon Comprehend` service is used by several other classes:+- **ComprehendToxicity** class is used to check the toxicity of text prompts using+ `AWS Comprehend service` and take actions based on the configuration+- **ComprehendPromptSafety** class is used to validate the safety of given prompt+ text, raising an error if unsafe content is detected based on the specified threshold+- **ComprehendPII** class is designed to handle+ `Personally Identifiable Information (PII)` moderation tasks,+ detecting and managing PII entities in text inputs+""" # noqa: E501from langchain_experimental.comprehend_moderation.amazon_comprehend_moderation import (AmazonComprehendModerationChain,)diff --git a/libs/experimental/langchain_experimental/cpal/__init__.py b/libs/experimental/langchain_experimental/cpal/__init__.pyindex e69de29bb2..5bbca54959 100644--- a/libs/experimental/langchain_experimental/cpal/__init__.py+++ b/libs/experimental/langchain_experimental/cpal/__init__.py@@ -0,0 +1,17 @@+"""+**Causal program-aided language (CPAL)** is a concept implemented in LangChain as+a chain for causal modeling and narrative decomposition.++CPAL improves upon the program-aided language (**PAL**) by incorporating+causal structure to prevent hallucination in language models,+particularly when dealing with complex narratives and math+problems with nested dependencies.++CPAL involves translating causal narratives into a stack of operations,+setting hypothetical conditions for causal models, and decomposing+narratives into story elements.++It allows for the creation of causal chains that define the relationships+between different elements in a narrative, enabling the modeling and analysis+of causal relationships within a given context.+"""diff --git a/libs/experimental/langchain_experimental/data_anonymizer/__init__.py b/libs/experimental/langchain_experimental/data_anonymizer/__init__.pyindex f43d6d98df..1e57f74345 100644--- a/libs/experimental/langchain_experimental/data_anonymizer/__init__.py+++ b/libs/experimental/langchain_experimental/data_anonymizer/__init__.py@@ -1,4 +1,13 @@-"""Data anonymizer package"""+"""**Data anonymizer** contains both Anonymizers and Deanonymizers.+It uses the [Microsoft Presidio](https://microsoft.github.io/presidio/) library.++**Anonymizers** are used to replace a `Personally Identifiable Information (PII)`+entity text with some other+value by applying a certain operator (e.g. replace, mask, redact, encrypt).++**Deanonymizers** are used to revert the anonymization operation+(e.g. to decrypt an encrypted text).+"""from langchain_experimental.data_anonymizer.presidio import (PresidioAnonymizer,PresidioReversibleAnonymizer,diff --git a/libs/experimental/langchain_experimental/fallacy_removal/__init__.py b/libs/experimental/langchain_experimental/fallacy_removal/__init__.pyindex 804990be4b..2ce9701be6 100644--- a/libs/experimental/langchain_experimental/fallacy_removal/__init__.py+++ b/libs/experimental/langchain_experimental/fallacy_removal/__init__.py@@ -1,4 +1,7 @@-"""The Chain runs a self-review of logical fallacies as determined by this paper \-categorizing and defining logical fallacies https://arxiv.org/pdf/2212.07425.pdf. \-Modeled after Constitutional AI and in same format, but applying logical \-fallacies as generalized rules to remove in output"""+"""**Fallacy Removal** Chain runs a self-review of logical fallacies+as determined by paper+[Robust and Explainable Identification of Logical Fallacies in Natural+Language Arguments](https://arxiv.org/pdf/2212.07425.pdf).+It is modeled after `Constitutional AI` and in the same format, but applying logical+fallacies as generalized rules to remove them in output.+"""diff --git a/libs/experimental/langchain_experimental/generative_agents/__init__.py b/libs/experimental/langchain_experimental/generative_agents/__init__.pyindex 5012c512aa..532c1e7020 100644--- a/libs/experimental/langchain_experimental/generative_agents/__init__.py+++ b/libs/experimental/langchain_experimental/generative_agents/__init__.py@@ -1,4 +1,4 @@-"""Generative Agents primitives."""+"""**Generative Agent** primitives."""from langchain_experimental.generative_agents.generative_agent import GenerativeAgentfrom langchain_experimental.generative_agents.memory import GenerativeAgentMemorydiff --git a/libs/experimental/langchain_experimental/graph_transformers/__init__.py b/libs/experimental/langchain_experimental/graph_transformers/__init__.pyindex 19d50bba6b..ada53d2403 100644--- a/libs/experimental/langchain_experimental/graph_transformers/__init__.py+++ b/libs/experimental/langchain_experimental/graph_transformers/__init__.py@@ -1,3 +1,4 @@+"""**Graph Transformers** transform Documents into Graph Documents."""from langchain_experimental.graph_transformers.diffbot import DiffbotGraphTransformerfrom langchain_experimental.graph_transformers.llm import LLMGraphTransformerdiff --git a/libs/experimental/langchain_experimental/graph_transformers/llm.py b/libs/experimental/langchain_experimental/graph_transformers/llm.pyindex 0d0888f84b..34ff03a009 100644--- a/libs/experimental/langchain_experimental/graph_transformers/llm.py+++ b/libs/experimental/langchain_experimental/graph_transformers/llm.py@@ -143,24 +143,26 @@ def map_to_base_relationship(rel: Any) -> Relationship:class LLMGraphTransformer:- """- A class designed to transform documents into graph-based documents using a LLM.+ """Transform documents into graph-based documents using a LLM.+It allows specifying constraints on the types of nodes and relationships to includein the output graph. The class doesn't support neither extract and node orrelationship propertiesArgs:llm (BaseLanguageModel): An instance of a language model supporting structured- output. allowed_nodes (List[str], optional): Specifies which node types are- allowed in the graph. Defaults to an empty list, allowing all node types.+ output.+ allowed_nodes (List[str], optional): Specifies which node types are+ allowed in the graph. Defaults to an empty list, allowing all node types.allowed_relationships (List[str], optional): Specifies which relationship types- are allowed in the graph. Defaults to an empty list, allowing all relationship- types.- prompt (Optional[ChatPromptTemplate], optional): The prompt to pass to the to- the LLM with additional instructions.+ are allowed in the graph. Defaults to an empty list, allowing all relationship+ types.+ prompt (Optional[ChatPromptTemplate], optional): The prompt to pass to+ the LLM with additional instructions.strict_mode (bool, optional): Determines whether the transformer should apply- filtering to strictly adhere to `allowed_nodes` and `allowed_relationships`.- Defaults to True.+ filtering to strictly adhere to `allowed_nodes` and `allowed_relationships`.+ Defaults to True.+Example:.. code-block:: pythonfrom langchain_experimental.graph_transformers import LLMGraphTransformerdiff --git a/libs/experimental/langchain_experimental/llm_bash/__init__.py b/libs/experimental/langchain_experimental/llm_bash/__init__.pyindex e1e848a1a8..cab96624b0 100644--- a/libs/experimental/langchain_experimental/llm_bash/__init__.py+++ b/libs/experimental/langchain_experimental/llm_bash/__init__.py@@ -1 +1,2 @@-"""Chain that interprets a prompt and executes bash code to perform bash operations."""+"""**LLM bash** is a chain that uses LLM to interpret a prompt and+executes **bash** code."""diff --git a/libs/experimental/langchain_experimental/llm_symbolic_math/__init__.py b/libs/experimental/langchain_experimental/llm_symbolic_math/__init__.pyindex d6cde9105a..a6c24bc0d3 100644--- a/libs/experimental/langchain_experimental/llm_symbolic_math/__init__.py+++ b/libs/experimental/langchain_experimental/llm_symbolic_math/__init__.py@@ -1,4 +1,4 @@-"""Chain that interprets a prompt and executes python code to do math.+"""Chain that interprets a prompt and **executes python code to do math**.-Heavily borrowed from llm_math, wrapper for SymPy+Heavily borrowed from `llm_math`, uses the [SymPy](https://www.sympy.org/) package."""diff --git a/libs/experimental/langchain_experimental/llms/__init__.py b/libs/experimental/langchain_experimental/llms/__init__.pyindex a45d1baab6..6825f1c9d7 100644--- a/libs/experimental/langchain_experimental/llms/__init__.py+++ b/libs/experimental/langchain_experimental/llms/__init__.py@@ -1,5 +1,6 @@-"""Experimental LLM wrappers."""-+"""Experimental **LLM** classes provide+access to the large language model (**LLM**) APIs and services.+"""from langchain_experimental.llms.jsonformer_decoder import JsonFormerfrom langchain_experimental.llms.llamaapi import ChatLlamaAPIfrom langchain_experimental.llms.lmformatenforcer_decoder import LMFormatEnforcerdiff --git a/libs/experimental/langchain_experimental/open_clip/__init__.py b/libs/experimental/langchain_experimental/open_clip/__init__.pyindex fdf9187540..ebf9afc60b 100644--- a/libs/experimental/langchain_experimental/open_clip/__init__.py+++ b/libs/experimental/langchain_experimental/open_clip/__init__.py@@ -1,3 +1,11 @@+"""**OpenCLIP Embeddings** model.++OpenCLIP is a multimodal model that can encode text and images into a shared space.++See this paper for more details: https://arxiv.org/abs/2103.00020+and [this repository](https://github.com/mlfoundations/open_clip) for details.++"""from .open_clip import OpenCLIPEmbeddings__all__ = ["OpenCLIPEmbeddings"]diff --git a/libs/experimental/langchain_experimental/pal_chain/__init__.py b/libs/experimental/langchain_experimental/pal_chain/__init__.pyindex ed25c20a5f..bba4e717f4 100644--- a/libs/experimental/langchain_experimental/pal_chain/__init__.py+++ b/libs/experimental/langchain_experimental/pal_chain/__init__.py@@ -1,10 +1,9 @@-"""Implements Program-Aided Language Models.+"""**PAL Chain** implements **Program-Aided Language** Models.-As in https://arxiv.org/pdf/2211.10435.pdf.+See the paper: https://arxiv.org/pdf/2211.10435.pdf.-This is vulnerable to arbitrary code execution:-https://github.com/langchain-ai/langchain/issues/5872-"""+This chain is vulnerable to [arbitrary code execution](https://github.com/langchain-ai/langchain/issues/5872).+""" # noqa: E501from langchain_experimental.pal_chain.base import PALChain__all__ = ["PALChain"]diff --git a/libs/experimental/langchain_experimental/plan_and_execute/__init__.py b/libs/experimental/langchain_experimental/plan_and_execute/__init__.pyindex e5cd8b934d..3cd4626294 100644--- a/libs/experimental/langchain_experimental/plan_and_execute/__init__.py+++ b/libs/experimental/langchain_experimental/plan_and_execute/__init__.py@@ -1,3 +1,7 @@+"""**Plan-and-execute agents** are planning tasks with a language model (LLM) and+executing them with a separate agent.++"""from langchain_experimental.plan_and_execute.agent_executor import PlanAndExecutefrom langchain_experimental.plan_and_execute.executors.agent_executor import (load_agent_executor,diff --git a/libs/experimental/langchain_experimental/prompt_injection_identifier/__init__.py b/libs/experimental/langchain_experimental/prompt_injection_identifier/__init__.pyindex 69f4248067..aba9151fc1 100644--- a/libs/experimental/langchain_experimental/prompt_injection_identifier/__init__.py+++ b/libs/experimental/langchain_experimental/prompt_injection_identifier/__init__.py@@ -1,4 +1,7 @@-"""HuggingFace Security toolkit."""+"""**HuggingFace Injection Identifier** is a tool that uses+[HuggingFace Prompt Injection model](https://huggingface.co/deepset/deberta-v3-base-injection)+to detect prompt injection attacks.+"""from langchain_experimental.prompt_injection_identifier.hugging_face_identifier import (HuggingFaceInjectionIdentifier,diff --git a/libs/experimental/langchain_experimental/prompt_injection_identifier/hugging_face_identifier.py b/libs/experimental/langchain_experimental/prompt_injection_identifier/hugging_face_identifier.pyindex 4f830d2c7f..a286847761 100644--- a/libs/experimental/langchain_experimental/prompt_injection_identifier/hugging_face_identifier.py+++ b/libs/experimental/langchain_experimental/prompt_injection_identifier/hugging_face_identifier.py@@ -50,7 +50,7 @@ def _model_default_factory(class HuggingFaceInjectionIdentifier(BaseTool):- """Tool that uses HuggingFace Prompt Injection to+ """Tool that uses HuggingFace Prompt Injection model todetect prompt injection attacks."""name: str = "hugging_face_injection_identifier"diff --git a/libs/experimental/langchain_experimental/prompts/__init__.py b/libs/experimental/langchain_experimental/prompts/__init__.pyindex 2bde8c4df1..f26c3fa5ad 100644--- a/libs/experimental/langchain_experimental/prompts/__init__.py+++ b/libs/experimental/langchain_experimental/prompts/__init__.py@@ -1,3 +1,5 @@+"""Unified method for **loading a prompt** from LangChainHub or local file system.+"""from langchain_experimental.prompts.load import load_prompt__all__ = ["load_prompt"]diff --git a/libs/experimental/langchain_experimental/recommenders/__init__.py b/libs/experimental/langchain_experimental/recommenders/__init__.pyindex ec06f55418..1c05b72faf 100644--- a/libs/experimental/langchain_experimental/recommenders/__init__.py+++ b/libs/experimental/langchain_experimental/recommenders/__init__.py@@ -1,4 +1,9 @@-"""Amazon Personalize primitives."""+"""**Amazon Personalize** primitives.++[Amazon Personalize](https://docs.aws.amazon.com/personalize/latest/dg/what-is-personalize.html)+is a fully managed machine learning service that uses your data to generate+item recommendations for your users.+""" # noqa: E501from langchain_experimental.recommenders.amazon_personalize import AmazonPersonalizefrom langchain_experimental.recommenders.amazon_personalize_chain import (AmazonPersonalizeChain,diff --git a/libs/experimental/langchain_experimental/recommenders/amazon_personalize.py b/libs/experimental/langchain_experimental/recommenders/amazon_personalize.pyindex 9b73f2e087..6f24bc02c8 100644--- a/libs/experimental/langchain_experimental/recommenders/amazon_personalize.py+++ b/libs/experimental/langchain_experimental/recommenders/amazon_personalize.py@@ -2,8 +2,9 @@ from typing import Any, List, Mapping, Optional, Sequenceclass AmazonPersonalize:- """Amazon Personalize Runtime wrapper for executing real-time operations:- https://docs.aws.amazon.com/personalize/latest/dg/API_Operations_Amazon_Personalize_Runtime.html+ """Amazon Personalize Runtime wrapper for executing real-time operations.++ See [this link for more details](https://docs.aws.amazon.com/personalize/latest/dg/API_Operations_Amazon_Personalize_Runtime.html).Args:campaign_arn: str, Optional: The Amazon Resource Name (ARN) of the campaigndiff --git a/libs/experimental/langchain_experimental/retrievers/__init__.py b/libs/experimental/langchain_experimental/retrievers/__init__.pyindex e69de29bb2..0f8ca9cb81 100644--- a/libs/experimental/langchain_experimental/retrievers/__init__.py+++ b/libs/experimental/langchain_experimental/retrievers/__init__.py@@ -0,0 +1,5 @@+"""**Retriever** class returns Documents given a text **query**.++It is more general than a vector store. A retriever does not need to be able to+store documents, only to return (or retrieve) it.+"""diff --git a/libs/experimental/langchain_experimental/rl_chain/__init__.py b/libs/experimental/langchain_experimental/rl_chain/__init__.pyindex ca558dd6f3..d2fb52fcd7 100644--- a/libs/experimental/langchain_experimental/rl_chain/__init__.py+++ b/libs/experimental/langchain_experimental/rl_chain/__init__.py@@ -1,3 +1,12 @@+"""+**RL (Reinforcement Learning) Chain** leverages the `Vowpal Wabbit (VW)` models+for reinforcement learning with a context, with the goal of modifying+the prompt before the LLM call.++[Vowpal Wabbit](https://vowpalwabbit.org/) provides fast, efficient,+and flexible online machine learning techniques for reinforcement learning,+supervised learning, and more.+"""import loggingfrom langchain_experimental.rl_chain.base import (diff --git a/libs/experimental/langchain_experimental/smart_llm/__init__.py b/libs/experimental/langchain_experimental/smart_llm/__init__.pyindex d1f83aab61..3e83d6c76e 100644--- a/libs/experimental/langchain_experimental/smart_llm/__init__.py+++ b/libs/experimental/langchain_experimental/smart_llm/__init__.py@@ -1,13 +1,13 @@-"""Chain for applying self-critique using the SmartGPT workflow.+"""**SmartGPT** chain is applying self-critique using the `SmartGPT` workflow.See details at https://youtu.be/wVzuvf9D9BUThe workflow performs these 3 steps:-1. **Ideate**: Pass the user prompt to an ideation LLM n_ideas times,+1. **Ideate**: Pass the user prompt to an `Ideation LLM` n_ideas times,each result is an "idea"-2. **Critique**: Pass the ideas to a critique LLM which looks for flaws in the ideas+2. **Critique**: Pass the ideas to a `Critique LLM` which looks for flaws in the ideas& picks the best one-3. **Resolve**: Pass the critique to a resolver LLM which improves upon the best idea+3. **Resolve**: Pass the critique to a `Resolver LLM` which improves upon the best idea& outputs only the (improved version of) the best outputIn total, the SmartGPT workflow will use n_ideas+2 LLM callsdiff --git a/libs/experimental/langchain_experimental/sql/__init__.py b/libs/experimental/langchain_experimental/sql/__init__.pyindex d14f9a0dea..05d4ecb1bd 100644--- a/libs/experimental/langchain_experimental/sql/__init__.py+++ b/libs/experimental/langchain_experimental/sql/__init__.py@@ -1,4 +1,4 @@-"""Chain for interacting with SQL Database."""+"""**SQL Chain** interacts with `SQL` Database."""from langchain_experimental.sql.base import SQLDatabaseChain, SQLDatabaseSequentialChain__all__ = ["SQLDatabaseChain", "SQLDatabaseSequentialChain"]diff --git a/libs/experimental/langchain_experimental/synthetic_data/__init__.py b/libs/experimental/langchain_experimental/synthetic_data/__init__.pyindex c5762a341c..ba1621a9d2 100644--- a/libs/experimental/langchain_experimental/synthetic_data/__init__.py+++ b/libs/experimental/langchain_experimental/synthetic_data/__init__.py@@ -1,3 +1,4 @@+"""Generate **synthetic data** using LLM and few-shot template."""from typing import Any, Dict, List, Optionalfrom langchain.chains.base import Chaindiff --git a/libs/experimental/langchain_experimental/tabular_synthetic_data/__init__.py b/libs/experimental/langchain_experimental/tabular_synthetic_data/__init__.pyindex e69de29bb2..d26ccf38f8 100644--- a/libs/experimental/langchain_experimental/tabular_synthetic_data/__init__.py+++ b/libs/experimental/langchain_experimental/tabular_synthetic_data/__init__.py@@ -0,0 +1 @@+"""Generate **tabular synthetic data** using LLM and few-shot template."""diff --git a/libs/experimental/langchain_experimental/text_splitter.py b/libs/experimental/langchain_experimental/text_splitter.pyindex a522f72c05..d53049e232 100644--- a/libs/experimental/langchain_experimental/text_splitter.py+++ b/libs/experimental/langchain_experimental/text_splitter.py@@ -1,3 +1,4 @@+"""Experimental **text splitter** based on semantic similarity."""import copyimport refrom typing import Any, Dict, Iterable, List, Literal, Optional, Sequence, Tuple, castdiff --git a/libs/experimental/langchain_experimental/tools/__init__.py b/libs/experimental/langchain_experimental/tools/__init__.pyindex 1d6b868d11..b3a746178b 100644--- a/libs/experimental/langchain_experimental/tools/__init__.py+++ b/libs/experimental/langchain_experimental/tools/__init__.py@@ -1,3 +1,4 @@+"""Experimental **Python REPL** tools."""from langchain_experimental.tools.python.tool import PythonAstREPLTool, PythonREPLTool__all__ = ["PythonREPLTool", "PythonAstREPLTool"]diff --git a/libs/experimental/langchain_experimental/tot/__init__.py b/libs/experimental/langchain_experimental/tot/__init__.pyindex c20812ccd5..9bd0639197 100644--- a/libs/experimental/langchain_experimental/tot/__init__.py+++ b/libs/experimental/langchain_experimental/tot/__init__.py@@ -1,7 +1,5 @@-"""Implementation of a Tree of Thought (ToT) chain based on the paper-"Large Language Model Guided Tree-of-Thought"--https://arxiv.org/pdf/2305.08291.pdf+"""Implementation of a **Tree of Thought (ToT)** chain based on the paper+[Large Language Model Guided Tree-of-Thought](https://arxiv.org/pdf/2305.08291.pdf).The Tree of Thought (ToT) chain uses a tree structure to explore the space ofpossible solutions to a problem.diff --git a/libs/experimental/langchain_experimental/utilities/__init__.py b/libs/experimental/langchain_experimental/utilities/__init__.pyindex d3aae0240d..4b7a4d5721 100644--- a/libs/experimental/langchain_experimental/utilities/__init__.py+++ b/libs/experimental/langchain_experimental/utilities/__init__.py@@ -1,3 +1,4 @@+"""Utility that simulates a standalone **Python REPL**."""from langchain_experimental.utilities.python import PythonREPL__all__ = ["PythonREPL"]