Skip to content

The agent engineering platform.

community[patch]: docstrings update (#20301)

Leonid Ganeline7cf2d2759d01
diff --git a/libs/community/langchain_community/agent_toolkits/connery/toolkit.py b/libs/community/langchain_community/agent_toolkits/connery/toolkit.py
index 03bbbf6231..e1a84fd6c1 100644
--- a/libs/community/langchain_community/agent_toolkits/connery/toolkit.py
+++ b/libs/community/langchain_community/agent_toolkits/connery/toolkit.py
@@ -9,7 +9,7 @@ from langchain_community.tools.connery import ConneryService
class ConneryToolkit(BaseToolkit):
"""
- A LangChain Toolkit with a list of Connery Actions as tools.
+ Toolkit with a list of Connery Actions as tools.
"""
tools: List[BaseTool]
diff --git a/libs/community/langchain_community/agent_toolkits/openapi/planner.py b/libs/community/langchain_community/agent_toolkits/openapi/planner.py
index 792a6dff66..281c8a49be 100644
--- a/libs/community/langchain_community/agent_toolkits/openapi/planner.py
+++ b/libs/community/langchain_community/agent_toolkits/openapi/planner.py
@@ -348,7 +348,7 @@ def create_openapi_agent(
allow_dangerous_requests: bool = False,
**kwargs: Any,
) -> Any:
- """Instantiate OpenAI API planner and controller for a given spec.
+ """Construct an OpenAI API planner and controller for a given spec.
Inject credentials via requests_wrapper.
diff --git a/libs/community/langchain_community/callbacks/flyte_callback.py b/libs/community/langchain_community/callbacks/flyte_callback.py
index 9fd953443f..3cd38f7eca 100644
--- a/libs/community/langchain_community/callbacks/flyte_callback.py
+++ b/libs/community/langchain_community/callbacks/flyte_callback.py
@@ -91,7 +91,7 @@ def analyze_text(
class FlyteCallbackHandler(BaseMetadataCallbackHandler, BaseCallbackHandler):
- """This callback handler that is used within a Flyte task."""
+ """Callback handler that is used within a Flyte task."""
def __init__(self) -> None:
"""Initialize callback handler."""
diff --git a/libs/community/langchain_community/callbacks/streamlit/mutable_expander.py b/libs/community/langchain_community/callbacks/streamlit/mutable_expander.py
index 0bb73f571a..9870e47224 100644
--- a/libs/community/langchain_community/callbacks/streamlit/mutable_expander.py
+++ b/libs/community/langchain_community/callbacks/streamlit/mutable_expander.py
@@ -9,14 +9,14 @@ if TYPE_CHECKING:
class ChildType(Enum):
- """The enumerator of the child type."""
+ """Enumerator of the child type."""
MARKDOWN = "MARKDOWN"
EXCEPTION = "EXCEPTION"
class ChildRecord(NamedTuple):
- """The child record as a NamedTuple."""
+ """Child record as a NamedTuple."""
type: ChildType
kwargs: Dict[str, Any]
@@ -24,7 +24,7 @@ class ChildRecord(NamedTuple):
class MutableExpander:
- """A Streamlit expander that can be renamed and dynamically expanded/collapsed."""
+ """Streamlit expander that can be renamed and dynamically expanded/collapsed."""
def __init__(self, parent_container: DeltaGenerator, label: str, expanded: bool):
"""Create a new MutableExpander.
@@ -51,7 +51,7 @@ class MutableExpander:
@property
def label(self) -> str:
- """The expander's label string."""
+ """Expander's label string."""
return self._label
@property
diff --git a/libs/community/langchain_community/callbacks/streamlit/streamlit_callback_handler.py b/libs/community/langchain_community/callbacks/streamlit/streamlit_callback_handler.py
index 89183fd5f4..0d065e95dd 100644
--- a/libs/community/langchain_community/callbacks/streamlit/streamlit_callback_handler.py
+++ b/libs/community/langchain_community/callbacks/streamlit/streamlit_callback_handler.py
@@ -40,7 +40,7 @@ class LLMThoughtState(Enum):
class ToolRecord(NamedTuple):
- """The tool record as a NamedTuple."""
+ """Tool record as a NamedTuple."""
name: str
input_str: str
diff --git a/libs/community/langchain_community/chat_message_histories/sql.py b/libs/community/langchain_community/chat_message_histories/sql.py
index f77deee61e..01cafeb9bc 100644
--- a/libs/community/langchain_community/chat_message_histories/sql.py
+++ b/libs/community/langchain_community/chat_message_histories/sql.py
@@ -21,7 +21,7 @@ logger = logging.getLogger(__name__)
class BaseMessageConverter(ABC):
- """Class that converts BaseMessage to the SQLAlchemy model."""
+ """Convert BaseMessage to the SQLAlchemy model."""
@abstractmethod
def from_sql_model(self, sql_message: Any) -> BaseMessage:
diff --git a/libs/community/langchain_community/chat_models/bedrock.py b/libs/community/langchain_community/chat_models/bedrock.py
index 587db5ee35..0555c9f2b0 100644
--- a/libs/community/langchain_community/chat_models/bedrock.py
+++ b/libs/community/langchain_community/chat_models/bedrock.py
@@ -196,7 +196,7 @@ _message_type_lookups = {"human": "user", "ai": "assistant"}
class BedrockChat(BaseChatModel, BedrockBase):
- """A chat model that uses the Bedrock API."""
+ """Chat model that uses the Bedrock API."""
@property
def _llm_type(self) -> str:
diff --git a/libs/community/langchain_community/chat_models/huggingface.py b/libs/community/langchain_community/chat_models/huggingface.py
index f459f58e1d..598a8ebc49 100644
--- a/libs/community/langchain_community/chat_models/huggingface.py
+++ b/libs/community/langchain_community/chat_models/huggingface.py
@@ -26,8 +26,7 @@ DEFAULT_SYSTEM_PROMPT = """You are a helpful, respectful, and honest assistant."
class ChatHuggingFace(BaseChatModel):
- """
- Wrapper for using Hugging Face LLM's as ChatModels.
+ """Hugging Face LLMs as ChatModels.
Works with `HuggingFaceTextGenInference`, `HuggingFaceEndpoint`,
and `HuggingFaceHub` LLMs.
diff --git a/libs/community/langchain_community/chat_models/litellm.py b/libs/community/langchain_community/chat_models/litellm.py
index b80fa2a6be..2f98033780 100644
--- a/libs/community/langchain_community/chat_models/litellm.py
+++ b/libs/community/langchain_community/chat_models/litellm.py
@@ -161,7 +161,7 @@ def _convert_message_to_dict(message: BaseMessage) -> dict:
class ChatLiteLLM(BaseChatModel):
- """A chat model that uses the LiteLLM API."""
+ """Chat model that uses the LiteLLM API."""
client: Any #: :meta private:
model: str = "gpt-3.5-turbo"
diff --git a/libs/community/langchain_community/chat_models/minimax.py b/libs/community/langchain_community/chat_models/minimax.py
index 5a5c281d3b..a315aa1f53 100644
--- a/libs/community/langchain_community/chat_models/minimax.py
+++ b/libs/community/langchain_community/chat_models/minimax.py
@@ -37,7 +37,7 @@ def _parse_chat_history(history: List[BaseMessage]) -> List:
class MiniMaxChat(MinimaxCommon, BaseChatModel):
- """Wrapper around Minimax large language models.
+ """MiniMax large language models.
To use, you should have the environment variable ``MINIMAX_GROUP_ID`` and
``MINIMAX_API_KEY`` set with your API token, or pass it as a named parameter to
diff --git a/libs/community/langchain_community/chat_models/moonshot.py b/libs/community/langchain_community/chat_models/moonshot.py
index 8df9ab612a..202a62d8ea 100644
--- a/libs/community/langchain_community/chat_models/moonshot.py
+++ b/libs/community/langchain_community/chat_models/moonshot.py
@@ -9,7 +9,7 @@ from langchain_community.llms.moonshot import MOONSHOT_SERVICE_URL_BASE, Moonsho
class MoonshotChat(MoonshotCommon, ChatOpenAI): # type: ignore[misc]
- """Wrapper around Moonshot large language models.
+ """Moonshot large language models.
To use, you should have the ``openai`` python package installed, and the
environment variable ``MOONSHOT_API_KEY`` set with your API key.
diff --git a/libs/community/langchain_community/chat_models/pai_eas_endpoint.py b/libs/community/langchain_community/chat_models/pai_eas_endpoint.py
index c0257d4d36..e438ad25ee 100644
--- a/libs/community/langchain_community/chat_models/pai_eas_endpoint.py
+++ b/libs/community/langchain_community/chat_models/pai_eas_endpoint.py
@@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
class PaiEasChatEndpoint(BaseChatModel):
- """Eas LLM Service chat model API.
+ """Alibaba Cloud PAI-EAS LLM Service chat model API.
To use, must have a deployed eas chat llm service on AliCloud. One can set the
environment variable ``eas_service_url`` and ``eas_service_token`` set with your eas
diff --git a/libs/community/langchain_community/chat_models/premai.py b/libs/community/langchain_community/chat_models/premai.py
index b0e9c83cf3..b509b8bf7d 100644
--- a/libs/community/langchain_community/chat_models/premai.py
+++ b/libs/community/langchain_community/chat_models/premai.py
@@ -159,7 +159,7 @@ def _messages_to_prompt_dict(
class ChatPremAI(BaseChatModel, BaseModel):
- """Use any LLM provider with Prem and Langchain.
+ """PremAI Chat models.
To use, you will need to have an API key. You can find your existing API Key
or generate a new one here: https://app.premai.io/api_keys/
@@ -357,6 +357,7 @@ def create_prem_retry_decorator(
max_retries: int = 1,
run_manager: Optional[Union[CallbackManagerForLLMRun]] = None,
) -> Callable[[Any], Any]:
+ """Create a retry decorator for PremAI API errors."""
import premai.models
errors = [
diff --git a/libs/community/langchain_community/chat_models/solar.py b/libs/community/langchain_community/chat_models/solar.py
index b5f64c37a1..dd466468fb 100644
--- a/libs/community/langchain_community/chat_models/solar.py
+++ b/libs/community/langchain_community/chat_models/solar.py
@@ -10,7 +10,7 @@ from langchain_community.llms.solar import SOLAR_SERVICE_URL_BASE, SolarCommon
class SolarChat(SolarCommon, ChatOpenAI): # type: ignore[misc]
- """Wrapper around Solar large language models.
+ """Solar large language models.
To use, you should have the ``openai`` python package installed, and the
environment variable ``SOLAR_API_KEY`` set with your API key.
diff --git a/libs/community/langchain_community/chat_models/sparkllm.py b/libs/community/langchain_community/chat_models/sparkllm.py
index 9305b0ce37..e3b36bed9b 100644
--- a/libs/community/langchain_community/chat_models/sparkllm.py
+++ b/libs/community/langchain_community/chat_models/sparkllm.py
@@ -89,7 +89,7 @@ def _convert_delta_to_message_chunk(
class ChatSparkLLM(BaseChatModel):
- """Wrapper around iFlyTek's Spark large language model.
+ """iFlyTek Spark large language model.
To use, you should pass `app_id`, `api_key`, `api_secret`
as a named parameter to the constructor OR set environment
diff --git a/libs/community/langchain_community/chat_models/tongyi.py b/libs/community/langchain_community/chat_models/tongyi.py
index 937d431193..fe3c2c1d41 100644
--- a/libs/community/langchain_community/chat_models/tongyi.py
+++ b/libs/community/langchain_community/chat_models/tongyi.py
@@ -61,6 +61,7 @@ logger = logging.getLogger(__name__)
def convert_dict_to_message(
_dict: Mapping[str, Any], is_chunk: bool = False
) -> Union[BaseMessage, BaseMessageChunk]:
+ """Convert a dict to a message."""
role = _dict["role"]
content = _dict["content"]
if role == "user":
@@ -88,6 +89,7 @@ def convert_dict_to_message(
def convert_message_chunk_to_message(message_chunk: BaseMessageChunk) -> BaseMessage:
+ """Convert a message chunk to a message."""
if isinstance(message_chunk, HumanMessageChunk):
return HumanMessage(content=message_chunk.content)
elif isinstance(message_chunk, AIMessageChunk):
diff --git a/libs/community/langchain_community/chat_models/yandex.py b/libs/community/langchain_community/chat_models/yandex.py
index 61ae77a471..424de6f8cf 100644
--- a/libs/community/langchain_community/chat_models/yandex.py
+++ b/libs/community/langchain_community/chat_models/yandex.py
@@ -53,7 +53,7 @@ def _parse_chat_history(history: List[BaseMessage]) -> List[Dict[str, str]]:
class ChatYandexGPT(_BaseYandexGPT, BaseChatModel):
- """Wrapper around YandexGPT large language models.
+ """YandexGPT large language models.
There are two authentication options for the service account
with the ``ai.languageModels.user`` role:
diff --git a/libs/community/langchain_community/chat_models/zhipuai.py b/libs/community/langchain_community/chat_models/zhipuai.py
index 23c9904b66..f367eb01c4 100644
--- a/libs/community/langchain_community/chat_models/zhipuai.py
+++ b/libs/community/langchain_community/chat_models/zhipuai.py
@@ -42,6 +42,7 @@ ZHIPUAI_API_BASE = "https://open.bigmodel.cn/api/paas/v4/chat/completions"
@contextmanager
def connect_sse(client: Any, method: str, url: str, **kwargs: Any) -> Iterator:
+ """Connect to a server-sent event stream."""
from httpx_sse import EventSource
with client.stream(method, url, **kwargs) as response:
@@ -52,6 +53,7 @@ def connect_sse(client: Any, method: str, url: str, **kwargs: Any) -> Iterator:
async def aconnect_sse(
client: Any, method: str, url: str, **kwargs: Any
) -> AsyncIterator:
+ """Async connect to a server-sent event stream."""
from httpx_sse import EventSource
async with client.stream(method, url, **kwargs) as response:
diff --git a/libs/community/langchain_community/docstore/arbitrary_fn.py b/libs/community/langchain_community/docstore/arbitrary_fn.py
index 6495d37b5e..a2eba5ddaf 100644
--- a/libs/community/langchain_community/docstore/arbitrary_fn.py
+++ b/libs/community/langchain_community/docstore/arbitrary_fn.py
@@ -6,7 +6,7 @@ from langchain_community.docstore.base import Docstore
class DocstoreFn(Docstore):
- """Langchain Docstore via arbitrary lookup function.
+ """Docstore via arbitrary lookup function.
This is useful when:
* it's expensive to construct an InMemoryDocstore/dict
diff --git a/libs/community/langchain_community/docstore/wikipedia.py b/libs/community/langchain_community/docstore/wikipedia.py
index cc7b6ae20e..5f09b3e0c0 100644
--- a/libs/community/langchain_community/docstore/wikipedia.py
+++ b/libs/community/langchain_community/docstore/wikipedia.py
@@ -9,7 +9,7 @@ from langchain_community.docstore.base import Docstore
class Wikipedia(Docstore):
- """Wrapper around wikipedia API."""
+ """Wikipedia API."""
def __init__(self) -> None:
"""Check that wikipedia package is installed."""
diff --git a/libs/community/langchain_community/document_compressors/openvino_rerank.py b/libs/community/langchain_community/document_compressors/openvino_rerank.py
index 8917c53cb1..182b1c159a 100644
--- a/libs/community/langchain_community/document_compressors/openvino_rerank.py
+++ b/libs/community/langchain_community/document_compressors/openvino_rerank.py
@@ -9,6 +9,8 @@ from langchain_core.pydantic_v1 import Field
class RerankRequest:
+ """Request for reranking."""
+
def __init__(self, query: Any = None, passages: Any = None):
self.query = query
self.passages = passages if passages is not None else []
diff --git a/libs/community/langchain_community/document_loaders/assemblyai.py b/libs/community/langchain_community/document_loaders/assemblyai.py
index 32ec943bdf..b7713d33bf 100644
--- a/libs/community/langchain_community/document_loaders/assemblyai.py
+++ b/libs/community/langchain_community/document_loaders/assemblyai.py
@@ -29,8 +29,7 @@ class TranscriptFormat(Enum):
class AssemblyAIAudioTranscriptLoader(BaseLoader):
- """
- Loader for AssemblyAI audio transcripts.
+ """Load AssemblyAI audio transcripts.
It uses the AssemblyAI API to transcribe audio files
and loads the transcribed text into one or more Documents,
@@ -110,7 +109,7 @@ class AssemblyAIAudioTranscriptLoader(BaseLoader):
class AssemblyAIAudioLoaderById(BaseLoader):
"""
- Loader for AssemblyAI audio transcripts.
+ Load AssemblyAI audio transcripts.
It uses the AssemblyAI API to get an existing transcription
and loads the transcribed text into one or more Documents,
diff --git a/libs/community/langchain_community/document_loaders/bilibili.py b/libs/community/langchain_community/document_loaders/bilibili.py
index 4757ee3c79..192311f59d 100644
--- a/libs/community/langchain_community/document_loaders/bilibili.py
+++ b/libs/community/langchain_community/document_loaders/bilibili.py
@@ -15,7 +15,7 @@ AV_PATTERN = re.compile(r"av[0-9]+")
class BiliBiliLoader(BaseLoader):
"""
- Loader for fetching transcripts from BiliBili videos.
+ Load fetching transcripts from BiliBili videos.
"""
def __init__(
diff --git a/libs/community/langchain_community/document_transformers/long_context_reorder.py b/libs/community/langchain_community/document_transformers/long_context_reorder.py
index 32eda6b482..a047c2d143 100644
--- a/libs/community/langchain_community/document_transformers/long_context_reorder.py
+++ b/libs/community/langchain_community/document_transformers/long_context_reorder.py
@@ -21,7 +21,9 @@ def _litm_reordering(documents: List[Document]) -> List[Document]:
class LongContextReorder(BaseDocumentTransformer, BaseModel):
- """Lost in the middle:
+ """Reorder long context.
+
+ Lost in the middle:
Performance degrades when models must access relevant information
in the middle of long contexts.
See: https://arxiv.org/abs//2307.03172"""
diff --git a/libs/community/langchain_community/document_transformers/nuclia_text_transform.py b/libs/community/langchain_community/document_transformers/nuclia_text_transform.py
index ed62f527e1..47ef5709f6 100644
--- a/libs/community/langchain_community/document_transformers/nuclia_text_transform.py
+++ b/libs/community/langchain_community/document_transformers/nuclia_text_transform.py
@@ -9,7 +9,8 @@ from langchain_community.tools.nuclia.tool import NucliaUnderstandingAPI
class NucliaTextTransformer(BaseDocumentTransformer):
- """
+ """Nuclia Text Transformer.
+
The Nuclia Understanding API splits into paragraphs and sentences,
identifies entities, provides a summary of the text and generates
embeddings for all sentences.
diff --git a/libs/community/langchain_community/embeddings/aleph_alpha.py b/libs/community/langchain_community/embeddings/aleph_alpha.py
index 41f970673f..24f6f9ebf2 100644
--- a/libs/community/langchain_community/embeddings/aleph_alpha.py
+++ b/libs/community/langchain_community/embeddings/aleph_alpha.py
@@ -183,7 +183,7 @@ class AlephAlphaAsymmetricSemanticEmbedding(BaseModel, Embeddings):
class AlephAlphaSymmetricSemanticEmbedding(AlephAlphaAsymmetricSemanticEmbedding):
- """The symmetric version of the Aleph Alpha's semantic embeddings.
+ """Symmetric version of the Aleph Alpha's semantic embeddings.
The main difference is that here, both the documents and
queries are embedded with a SemanticRepresentation.Symmetric
diff --git a/libs/community/langchain_community/embeddings/databricks.py b/libs/community/langchain_community/embeddings/databricks.py
index ce4a7e856b..8ea3867fa4 100644
--- a/libs/community/langchain_community/embeddings/databricks.py
+++ b/libs/community/langchain_community/embeddings/databricks.py
@@ -12,7 +12,7 @@ def _chunk(texts: List[str], size: int) -> Iterator[List[str]]:
class DatabricksEmbeddings(MlflowEmbeddings):
- """Wrapper around embeddings LLMs in Databricks.
+ """Databricks embeddings.
To use, you should have the ``mlflow`` python package installed.
For more information, see https://mlflow.org/docs/latest/llms/deployments.
diff --git a/libs/community/langchain_community/embeddings/infinity_local.py b/libs/community/langchain_community/embeddings/infinity_local.py
index a4f0d513ec..3b94f71632 100644
--- a/libs/community/langchain_community/embeddings/infinity_local.py
+++ b/libs/community/langchain_community/embeddings/infinity_local.py
@@ -13,7 +13,9 @@ logger = getLogger(__name__)
class InfinityEmbeddingsLocal(BaseModel, Embeddings):
- """Optimized Embedding models https://github.com/michaelfeil/infinity
+ """Optimized Infinity embedding models.
+
+ https://github.com/michaelfeil/infinity
This class deploys a local Infinity instance to embed text.
The class requires async usage.
diff --git a/libs/community/langchain_community/embeddings/javelin_ai_gateway.py b/libs/community/langchain_community/embeddings/javelin_ai_gateway.py
index 6ee376097e..61baac869d 100644
--- a/libs/community/langchain_community/embeddings/javelin_ai_gateway.py
+++ b/libs/community/langchain_community/embeddings/javelin_ai_gateway.py
@@ -12,8 +12,7 @@ def _chunk(texts: List[str], size: int) -> Iterator[List[str]]:
class JavelinAIGatewayEmbeddings(Embeddings, BaseModel):
- """
- Wrapper around embeddings LLMs in the Javelin AI Gateway.
+ """Javelin AI Gateway embeddings.
To use, you should have the ``javelin_sdk`` python package installed.
For more information, see https://docs.getjavelin.io
diff --git a/libs/community/langchain_community/embeddings/mlflow_gateway.py b/libs/community/langchain_community/embeddings/mlflow_gateway.py
index ad54761cbe..6e2fad408a 100644
--- a/libs/community/langchain_community/embeddings/mlflow_gateway.py
+++ b/libs/community/langchain_community/embeddings/mlflow_gateway.py
@@ -13,8 +13,7 @@ def _chunk(texts: List[str], size: int) -> Iterator[List[str]]:
class MlflowAIGatewayEmbeddings(Embeddings, BaseModel):
- """
- Wrapper around embeddings LLMs in the MLflow AI Gateway.
+ """MLflow AI Gateway embeddings.
To use, you should have the ``mlflow[gateway]`` python package installed.
For more information, see https://mlflow.org/docs/latest/gateway/index.html.
diff --git a/libs/community/langchain_community/embeddings/nemo.py b/libs/community/langchain_community/embeddings/nemo.py
index 7ae0ab5da6..f0c33c6796 100644
--- a/libs/community/langchain_community/embeddings/nemo.py
+++ b/libs/community/langchain_community/embeddings/nemo.py
@@ -42,6 +42,8 @@ def is_endpoint_live(url: str, headers: Optional[dict], payload: Any) -> bool:
class NeMoEmbeddings(BaseModel, Embeddings):
+ """NeMo embedding models."""
+
batch_size: int = 16
model: str = "NV-Embed-QA-003"
api_endpoint_url: str = "http://localhost:8088/v1/embeddings"
diff --git a/libs/community/langchain_community/graphs/networkx_graph.py b/libs/community/langchain_community/graphs/networkx_graph.py
index 7cafed6253..59c2647986 100644
--- a/libs/community/langchain_community/graphs/networkx_graph.py
+++ b/libs/community/langchain_community/graphs/networkx_graph.py
@@ -7,7 +7,7 @@ KG_TRIPLE_DELIMITER = "<|>"
class KnowledgeTriple(NamedTuple):
- """A triple in the graph."""
+ """Knowledge triple in the graph."""
subject: str
predicate: str
diff --git a/libs/community/langchain_community/indexes/base.py b/libs/community/langchain_community/indexes/base.py
index 46ef5bf2ef..97805d91e7 100644
--- a/libs/community/langchain_community/indexes/base.py
+++ b/libs/community/langchain_community/indexes/base.py
@@ -8,7 +8,7 @@ NAMESPACE_UUID = uuid.UUID(int=1984)
class RecordManager(ABC):
- """An abstract base class representing the interface for a record manager."""
+ """Abstract base class for a record manager."""
def __init__(
self,
diff --git a/libs/community/langchain_community/llms/cloudflare_workersai.py b/libs/community/langchain_community/llms/cloudflare_workersai.py
index 840acdbdb8..54b41418c4 100644
--- a/libs/community/langchain_community/llms/cloudflare_workersai.py
+++ b/libs/community/langchain_community/llms/cloudflare_workersai.py
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
class CloudflareWorkersAI(LLM):
- """Langchain LLM class to help to access Cloudflare Workers AI service.
+ """Cloudflare Workers AI service.
To use, you must provide an API token and
account ID to access Cloudflare Workers AI, and
diff --git a/libs/community/langchain_community/llms/databricks.py b/libs/community/langchain_community/llms/databricks.py
index 715530f7a7..0debf87353 100644
--- a/libs/community/langchain_community/llms/databricks.py
+++ b/libs/community/langchain_community/llms/databricks.py
@@ -161,7 +161,7 @@ class _DatabricksClusterDriverProxyClient(_DatabricksClientBase):
def get_repl_context() -> Any:
- """Gets the notebook REPL context if running inside a Databricks notebook.
+ """Get the notebook REPL context if running inside a Databricks notebook.
Returns None otherwise.
"""
try:
@@ -175,7 +175,7 @@ def get_repl_context() -> Any:
def get_default_host() -> str:
- """Gets the default Databricks workspace hostname.
+ """Get the default Databricks workspace hostname.
Raises an error if the hostname cannot be automatically determined.
"""
host = os.getenv("DATABRICKS_HOST")
@@ -195,7 +195,7 @@ def get_default_host() -> str:
def get_default_api_token() -> str:
- """Gets the default Databricks personal access token.
+ """Get the default Databricks personal access token.
Raises an error if the token cannot be automatically determined.
"""
if api_token := os.getenv("DATABRICKS_TOKEN"):
diff --git a/libs/community/langchain_community/llms/edenai.py b/libs/community/langchain_community/llms/edenai.py
index fd1842d72a..e397aa7a2a 100644
--- a/libs/community/langchain_community/llms/edenai.py
+++ b/libs/community/langchain_community/llms/edenai.py
@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
class EdenAI(LLM):
- """Wrapper around edenai models.
+ """EdenAI models.
To use, you should have
the environment variable ``EDENAI_API_KEY`` set with your API token.
diff --git a/libs/community/langchain_community/llms/human.py b/libs/community/langchain_community/llms/human.py
index ae1e627f30..39473c0ee1 100644
--- a/libs/community/langchain_community/llms/human.py
+++ b/libs/community/langchain_community/llms/human.py
@@ -33,9 +33,7 @@ def _collect_user_input(
class HumanInputLLM(LLM):
- """
- It returns user input as the response.
- """
+ """User input as the response."""
input_func: Callable = Field(default_factory=lambda: _collect_user_input)
prompt_func: Callable[[str], None] = Field(default_factory=lambda: _display_prompt)
diff --git a/libs/community/langchain_community/llms/ipex_llm.py b/libs/community/langchain_community/llms/ipex_llm.py
index af847786d9..ed03770180 100644
--- a/libs/community/langchain_community/llms/ipex_llm.py
+++ b/libs/community/langchain_community/llms/ipex_llm.py
@@ -12,7 +12,7 @@ logger = logging.getLogger(__name__)
class IpexLLM(LLM):
- """Wrapper around the IpexLLM model
+ """IpexLLM model.
Example:
.. code-block:: python
diff --git a/libs/community/langchain_community/llms/konko.py b/libs/community/langchain_community/llms/konko.py
index 7bcd471d4e..97ac3fdc8a 100644
--- a/libs/community/langchain_community/llms/konko.py
+++ b/libs/community/langchain_community/llms/konko.py
@@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
class Konko(LLM):
- """Wrapper around Konko AI models.
+ """Konko AI models.
To use, you'll need an API key. This can be passed in as init param
``konko_api_key`` or set as environment variable ``KONKO_API_KEY``.
diff --git a/libs/community/langchain_community/llms/layerup_security.py b/libs/community/langchain_community/llms/layerup_security.py
index 6faf14e1e3..2a383cd2ee 100644
--- a/libs/community/langchain_community/llms/layerup_security.py
+++ b/libs/community/langchain_community/llms/layerup_security.py
@@ -9,6 +9,14 @@ logger = logging.getLogger(__name__)
def default_guardrail_violation_handler(violation: dict) -> str:
+ """Default guardrail violation handler.
+
+ Args:
+ violation (dict): The violation dictionary.
+
+ Returns:
+ str: The canned response.
+ """
if violation.get("canned_response"):
return violation["canned_response"]
guardrail_name = (
@@ -22,6 +30,8 @@ def default_guardrail_violation_handler(violation: dict) -> str:
class LayerupSecurity(LLM):
+ """Layerup Security LLM service."""
+
llm: LLM
layerup_api_key: str
layerup_api_base_url: str = "https://api.uselayerup.com/v1"
diff --git a/libs/community/langchain_community/llms/loading.py b/libs/community/langchain_community/llms/loading.py
index 83a459265e..05025b8e7a 100644
--- a/libs/community/langchain_community/llms/loading.py
+++ b/libs/community/langchain_community/llms/loading.py
@@ -34,6 +34,7 @@ def load_llm_from_config(config: dict, **kwargs: Any) -> BaseLLM:
def load_llm(file: Union[str, Path], **kwargs: Any) -> BaseLLM:
+ """Load LLM from a file."""
# Convert file to Path object.
if isinstance(file, str):
file_path = Path(file)
diff --git a/libs/community/langchain_community/llms/mlflow.py b/libs/community/langchain_community/llms/mlflow.py
index ff2817de8a..9b27ed57d8 100644
--- a/libs/community/langchain_community/llms/mlflow.py
+++ b/libs/community/langchain_community/llms/mlflow.py
@@ -9,7 +9,7 @@ from langchain_core.pydantic_v1 import Field, PrivateAttr
class Mlflow(LLM):
- """Wrapper around completions LLMs in MLflow.
+ """MLflow LLM service.
To use, you should have the `mlflow[genai]` python package installed.
For more information, see https://mlflow.org/docs/latest/llms/deployments.
diff --git a/libs/community/langchain_community/llms/mlflow_ai_gateway.py b/libs/community/langchain_community/llms/mlflow_ai_gateway.py
index 776307a6bd..1909b8901a 100644
--- a/libs/community/langchain_community/llms/mlflow_ai_gateway.py
+++ b/libs/community/langchain_community/llms/mlflow_ai_gateway.py
@@ -21,8 +21,7 @@ class Params(BaseModel, extra=Extra.allow): # type: ignore[call-arg]
class MlflowAIGateway(LLM):
- """
- Wrapper around completions LLMs in the MLflow AI Gateway.
+ """MLflow AI Gateway LLMs.
To use, you should have the ``mlflow[gateway]`` python package installed.
For more information, see https://mlflow.org/docs/latest/gateway/index.html.
diff --git a/libs/community/langchain_community/llms/moonshot.py b/libs/community/langchain_community/llms/moonshot.py
index 7fa5db33d1..d72659f126 100644
--- a/libs/community/langchain_community/llms/moonshot.py
+++ b/libs/community/langchain_community/llms/moonshot.py
@@ -31,6 +31,8 @@ class _MoonshotClient(BaseModel):
class MoonshotCommon(BaseModel):
+ """Common parameters for Moonshot LLMs."""
+
_client: _MoonshotClient
base_url: str = MOONSHOT_SERVICE_URL_BASE
moonshot_api_key: Optional[SecretStr] = Field(default=None, alias="api_key")
diff --git a/libs/community/langchain_community/llms/opaqueprompts.py b/libs/community/langchain_community/llms/opaqueprompts.py
index 34f14c515c..9be25d4d23 100644
--- a/libs/community/langchain_community/llms/opaqueprompts.py
+++ b/libs/community/langchain_community/llms/opaqueprompts.py
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
class OpaquePrompts(LLM):
- """An LLM wrapper that uses OpaquePrompts to sanitize prompts.
+ """LLM that uses OpaquePrompts to sanitize prompts.
Wraps another LLM and sanitizes prompts before passing it to the LLM, then
de-sanitizes the response.
diff --git a/libs/community/langchain_community/llms/promptlayer_openai.py b/libs/community/langchain_community/llms/promptlayer_openai.py
index cb904476e8..15456a7399 100644
--- a/libs/community/langchain_community/llms/promptlayer_openai.py
+++ b/libs/community/langchain_community/llms/promptlayer_openai.py
@@ -124,7 +124,7 @@ class PromptLayerOpenAI(OpenAI):
class PromptLayerOpenAIChat(OpenAIChat):
- """Wrapper around OpenAI large language models.
+ """PromptLayer OpenAI large language models.
To use, you should have the ``openai`` and ``promptlayer`` python
package installed, and the environment variable ``OPENAI_API_KEY``
diff --git a/libs/community/langchain_community/llms/sagemaker_endpoint.py b/libs/community/langchain_community/llms/sagemaker_endpoint.py
index 7ca76fc411..7027a3ffa5 100644
--- a/libs/community/langchain_community/llms/sagemaker_endpoint.py
+++ b/libs/community/langchain_community/llms/sagemaker_endpoint.py
@@ -15,8 +15,7 @@ OUTPUT_TYPE = TypeVar("OUTPUT_TYPE", bound=Union[str, List[List[float]], Iterato
class LineIterator:
- """
- A helper class for parsing the byte stream input.
+ """Parse the byte stream input.
The output of the model will be in the following format:
@@ -74,7 +73,7 @@ class LineIterator:
class ContentHandlerBase(Generic[INPUT_TYPE, OUTPUT_TYPE]):
- """A handler class to transform input from LLM to a
+ """Handler class to transform input from LLM to a
format that SageMaker endpoint expects.
Similarly, the class handles transforming output from the
diff --git a/libs/community/langchain_community/llms/sparkllm.py b/libs/community/langchain_community/llms/sparkllm.py
index e7596929c9..467952f35c 100644
--- a/libs/community/langchain_community/llms/sparkllm.py
+++ b/libs/community/langchain_community/llms/sparkllm.py
@@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
class SparkLLM(LLM):
- """Wrapper around iFlyTek's Spark large language model.
+ """iFlyTek Spark large language model.
To use, you should pass `app_id`, `api_key`, `api_secret`
as a named parameter to the constructor OR set environment
diff --git a/libs/community/langchain_community/llms/titan_takeoff.py b/libs/community/langchain_community/llms/titan_takeoff.py
index 9140aa0bc3..b2007ccdea 100644
--- a/libs/community/langchain_community/llms/titan_takeoff.py
+++ b/libs/community/langchain_community/llms/titan_takeoff.py
@@ -10,7 +10,7 @@ from langchain_community.llms.utils import enforce_stop_tokens
class TitanTakeoff(LLM):
- """Wrapper around Titan Takeoff APIs."""
+ """Titan Takeoff API LLMs."""
base_url: str = "http://localhost:8000"
"""Specifies the baseURL to use for the Titan Takeoff API.
diff --git a/libs/community/langchain_community/llms/vertexai.py b/libs/community/langchain_community/llms/vertexai.py
index b93cdbafb7..b8ba8c54f2 100644
--- a/libs/community/langchain_community/llms/vertexai.py
+++ b/libs/community/langchain_community/llms/vertexai.py
@@ -40,12 +40,12 @@ stream_completion_with_retry = None
def is_codey_model(model_name: str) -> bool:
- """Returns True if the model name is a Codey model."""
+ """Return True if the model name is a Codey model."""
return "code" in model_name
def is_gemini_model(model_name: str) -> bool:
- """Returns True if the model name is a Gemini model."""
+ """Return True if the model name is a Gemini model."""
return model_name is not None and "gemini" in model_name
@@ -397,7 +397,7 @@ class VertexAI(_VertexAICommon, BaseLLM):
alternative_import="langchain_google_vertexai.VertexAIModelGarden",
)
class VertexAIModelGarden(_VertexAIBase, BaseLLM):
- """Large language models served from Vertex AI Model Garden."""
+ """Vertex AI Model Garden large language models."""
client: "PredictionServiceClient" = None #: :meta private:
async_client: "PredictionServiceAsyncClient" = None #: :meta private:
diff --git a/libs/community/langchain_community/retrievers/arcee.py b/libs/community/langchain_community/retrievers/arcee.py
index dbe4449fd9..b7e645c934 100644
--- a/libs/community/langchain_community/retrievers/arcee.py
+++ b/libs/community/langchain_community/retrievers/arcee.py
@@ -10,7 +10,7 @@ from langchain_community.utilities.arcee import ArceeWrapper, DALMFilter
class ArceeRetriever(BaseRetriever):
- """Retriever for Arcee's Domain Adapted Language Models (DALMs).
+ """Arcee Domain Adapted Language Models (DALMs) retriever.
To use, set the ``ARCEE_API_KEY`` environment variable with your Arcee API key,
or pass ``arcee_api_key`` as a named parameter.
diff --git a/libs/community/langchain_community/retrievers/you.py b/libs/community/langchain_community/retrievers/you.py
index 5d3b19e430..8ce080545a 100644
--- a/libs/community/langchain_community/retrievers/you.py
+++ b/libs/community/langchain_community/retrievers/you.py
@@ -11,7 +11,8 @@ from langchain_community.utilities import YouSearchAPIWrapper
class YouRetriever(BaseRetriever, YouSearchAPIWrapper):
- """`You` retriever that uses You.com's search API.
+ """You.com Search API retriever.
+
It wraps results() to get_relevant_documents
It uses all YouSearchAPIWrapper arguments without any change.
"""
diff --git a/libs/community/langchain_community/tools/cogniswitch/tool.py b/libs/community/langchain_community/tools/cogniswitch/tool.py
index e2878e6ed5..514b3b97b1 100644
--- a/libs/community/langchain_community/tools/cogniswitch/tool.py
+++ b/libs/community/langchain_community/tools/cogniswitch/tool.py
@@ -8,8 +8,8 @@ from langchain_core.tools import BaseTool
class CogniswitchKnowledgeRequest(BaseTool):
- """
- A tool for interacting with the Cogniswitch service to answer questions.
+ """Tool that uses the Cogniswitch service to answer questions.
+
name: str = "cogniswitch_knowledge_request"
description: str = (
"A wrapper around cogniswitch service to answer the question
@@ -81,9 +81,9 @@ class CogniswitchKnowledgeRequest(BaseTool):
class CogniswitchKnowledgeStatus(BaseTool):
- """
- A cogniswitch tool for interacting with the Cogniswitch services to know the
+ """Tool that uses the Cogniswitch services to get the
status of the document or url uploaded.
+
name: str = "cogniswitch_knowledge_status"
description: str = (
"A wrapper around cogniswitch services to know the status of
@@ -181,8 +181,8 @@ class CogniswitchKnowledgeStatus(BaseTool):
class CogniswitchKnowledgeSourceFile(BaseTool):
- """
- A cogniswitch tool for interacting with the Cogniswitch services to store data.
+ """Tool that uses the Cogniswitch services to store data from file.
+
name: str = "cogniswitch_knowledge_source_file"
description: str = (
"This calls the CogniSwitch services to analyze & store data from a file.
@@ -294,8 +294,8 @@ class CogniswitchKnowledgeSourceFile(BaseTool):
class CogniswitchKnowledgeSourceURL(BaseTool):
- """
- A cogniswitch tool for interacting with the Cogniswitch services to store data.
+ """Tool that uses the Cogniswitch services to store data from a URL.
+
name: str = "cogniswitch_knowledge_source_url"
description: str = (
"This calls the CogniSwitch services to analyze & store data from a url.
diff --git a/libs/community/langchain_community/tools/connery/service.py b/libs/community/langchain_community/tools/connery/service.py
index decc9a440f..b8606a9317 100644
--- a/libs/community/langchain_community/tools/connery/service.py
+++ b/libs/community/langchain_community/tools/connery/service.py
@@ -10,8 +10,8 @@ from langchain_community.tools.connery.tool import ConneryAction
class ConneryService(BaseModel):
- """
- A service for interacting with the Connery Runner API.
+ """Service for interacting with the Connery Runner API.
+
It gets the list of available actions from the Connery Runner,
wraps them in ConneryAction Tools and returns them to the user.
It also provides a method for running the actions.
diff --git a/libs/community/langchain_community/tools/connery/tool.py b/libs/community/langchain_community/tools/connery/tool.py
index 359a4dd75e..51138714e2 100644
--- a/libs/community/langchain_community/tools/connery/tool.py
+++ b/libs/community/langchain_community/tools/connery/tool.py
@@ -13,9 +13,7 @@ from langchain_community.tools.connery.models import Action, Parameter
class ConneryAction(BaseTool):
- """
- A LangChain Tool wrapping a Connery Action.
- """
+ """Connery Action tool."""
name: str
description: str
diff --git a/libs/community/langchain_community/tools/office365/events_search.py b/libs/community/langchain_community/tools/office365/events_search.py
index 8cb16f7a29..f74927e507 100644
--- a/libs/community/langchain_community/tools/office365/events_search.py
+++ b/libs/community/langchain_community/tools/office365/events_search.py
@@ -54,7 +54,7 @@ class SearchEventsInput(BaseModel):
class O365SearchEvents(O365BaseTool):
- """Class for searching calendar events in Office 365
+ """Search calendar events in Office 365.
Free, but setup is required
"""
diff --git a/libs/community/langchain_community/tools/office365/messages_search.py b/libs/community/langchain_community/tools/office365/messages_search.py
index ad26e42de4..3b12b2a15a 100644
--- a/libs/community/langchain_community/tools/office365/messages_search.py
+++ b/libs/community/langchain_community/tools/office365/messages_search.py
@@ -53,9 +53,9 @@ class SearchEmailsInput(BaseModel):
class O365SearchEmails(O365BaseTool):
- """Class for searching email messages in Office 365
+ """Search email messages in Office 365.
- Free, but setup is required
+ Free, but setup is required.
"""
name: str = "messages_search"
diff --git a/libs/community/langchain_community/tools/office365/send_message.py b/libs/community/langchain_community/tools/office365/send_message.py
index cd7abef976..828e9e4fa6 100644
--- a/libs/community/langchain_community/tools/office365/send_message.py
+++ b/libs/community/langchain_community/tools/office365/send_message.py
@@ -32,7 +32,7 @@ class SendMessageSchema(BaseModel):
class O365SendMessage(O365BaseTool):
- """Tool for sending an email in Office 365."""
+ """Send an email in Office 365."""
name: str = "send_email"
description: str = (
diff --git a/libs/community/langchain_community/tools/office365/utils.py b/libs/community/langchain_community/tools/office365/utils.py
index f13c10dde1..168fe1ccb4 100644
--- a/libs/community/langchain_community/tools/office365/utils.py
+++ b/libs/community/langchain_community/tools/office365/utils.py
@@ -36,7 +36,7 @@ def clean_body(body: str) -> str:
def authenticate() -> Account:
- """Authenticate using the Microsoft Grah API"""
+ """Authenticate using the Microsoft Graph API"""
try:
from O365 import Account
except ImportError as e:
diff --git a/libs/community/langchain_community/tools/you/tool.py b/libs/community/langchain_community/tools/you/tool.py
index 75e18a1b62..75b06bd013 100644
--- a/libs/community/langchain_community/tools/you/tool.py
+++ b/libs/community/langchain_community/tools/you/tool.py
@@ -12,11 +12,13 @@ from langchain_community.utilities.you import YouSearchAPIWrapper
class YouInput(BaseModel):
+ """Input schema for the you.com tool."""
+
query: str = Field(description="should be a search query")
class YouSearchTool(BaseTool):
- """Tool that searches the you.com API"""
+ """Tool that searches the you.com API."""
name = "you_search"
description = (
diff --git a/libs/community/langchain_community/tools/zapier/tool.py b/libs/community/langchain_community/tools/zapier/tool.py
index 3d5f395554..22a25b13a9 100644
--- a/libs/community/langchain_community/tools/zapier/tool.py
+++ b/libs/community/langchain_community/tools/zapier/tool.py
@@ -82,8 +82,9 @@ from langchain_community.utilities.zapier import ZapierNLAWrapper
class ZapierNLARunAction(BaseTool):
- """
- Args:
+ """Tool to run a specific action from the user's exposed actions.
+
+ Params:
action_id: a specific action ID (from list actions) of the action to execute
(the set api_key must be associated with the action owner)
instructions: a natural language instruction string for using the action
@@ -167,11 +168,7 @@ ZapierNLARunAction.__doc__ = (
class ZapierNLAListActions(BaseTool):
- """
- Args:
- None
-
- """
+ """Tool to list all exposed actions for the user."""
name: str = "ZapierNLA_list_actions"
description: str = BASE_ZAPIER_TOOL_PROMPT + (
diff --git a/libs/community/langchain_community/utilities/astradb.py b/libs/community/langchain_community/utilities/astradb.py
index c113d66079..1df7673049 100644
--- a/libs/community/langchain_community/utilities/astradb.py
+++ b/libs/community/langchain_community/utilities/astradb.py
@@ -14,6 +14,8 @@ if TYPE_CHECKING:
class SetupMode(Enum):
+ """Setup mode for AstraDBEnvironment as enumerator."""
+
SYNC = 1
ASYNC = 2
OFF = 3
diff --git a/libs/community/langchain_community/utilities/pebblo.py b/libs/community/langchain_community/utilities/pebblo.py
index 5319b17400..da65a5835d 100644
--- a/libs/community/langchain_community/utilities/pebblo.py
+++ b/libs/community/langchain_community/utilities/pebblo.py
@@ -62,7 +62,7 @@ logger = logging.getLogger(__name__)
class Runtime(BaseModel):
- """This class represents a Runtime.
+ """Pebblo Runtime.
Args:
type (Optional[str]): Runtime type. Defaults to ""
@@ -90,7 +90,7 @@ class Runtime(BaseModel):
class Framework(BaseModel):
- """This class represents a Framework instance.
+ """Pebblo Framework instance.
Args:
name (str): Name of the Framework.
@@ -102,7 +102,7 @@ class Framework(BaseModel):
class App(BaseModel):
- """This class represents an AI application.
+ """Pebblo AI application.
Args:
name (str): Name of the app.
@@ -124,7 +124,7 @@ class App(BaseModel):
class Doc(BaseModel):
- """This class represents a pebblo document.
+ """Pebblo document.
Args:
name (str): Name of app originating this document.
@@ -148,8 +148,8 @@ class Doc(BaseModel):
def get_full_path(path: str) -> str:
- """Return absolute local path for a local file/directory,
- for network related path, return as is.
+ """Return an absolute local path for a local file/directory,
+ for a network related path, return as is.
Args:
path (str): Relative path to be resolved.
@@ -184,7 +184,7 @@ def get_loader_type(loader: str) -> str:
def get_loader_full_path(loader: BaseLoader) -> str:
- """Return absolute source path of source of loader based on the
+ """Return an absolute source path of source of loader based on the
keys present in Document object from loader.
Args:
@@ -266,7 +266,7 @@ def get_runtime() -> Tuple[Framework, Runtime]:
def get_ip() -> str:
- """Fetch local runtime ip address
+ """Fetch local runtime ip address.
Returns:
str: IP address
diff --git a/libs/community/langchain_community/utilities/vertexai.py b/libs/community/langchain_community/utilities/vertexai.py
index 1dc1f14b3f..6a8023b36c 100644
--- a/libs/community/langchain_community/utilities/vertexai.py
+++ b/libs/community/langchain_community/utilities/vertexai.py
@@ -22,7 +22,7 @@ def create_retry_decorator(
Union[AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun]
] = None,
) -> Callable[[Any], Any]:
- """Creates a retry decorator for Vertex / Palm LLMs."""
+ """Create a retry decorator for Vertex / Palm LLMs."""
import google.api_core
errors = [
@@ -82,7 +82,7 @@ def init_vertexai(
def get_client_info(module: Optional[str] = None) -> "ClientInfo":
- r"""Returns a custom user agent header.
+ r"""Return a custom user agent header.
Args:
module (Optional[str]):
@@ -109,7 +109,7 @@ def get_client_info(module: Optional[str] = None) -> "ClientInfo":
def load_image_from_gcs(path: str, project: Optional[str] = None) -> "Image":
- """Loads im Image from GCS."""
+ """Load an image from Google Cloud Storage."""
try:
from google.cloud import storage
except ImportError:
diff --git a/libs/community/langchain_community/utilities/you.py b/libs/community/langchain_community/utilities/you.py
index 119b79bc0e..b74841c868 100644
--- a/libs/community/langchain_community/utilities/you.py
+++ b/libs/community/langchain_community/utilities/you.py
@@ -29,7 +29,7 @@ class YouHit(YouHitMetadata):
class YouAPIOutput(BaseModel):
- """The output from you.com api"""
+ """Output from you.com API."""
hits: List[YouHit] = Field(
description="A list of dictionaries containing the results"
@@ -37,7 +37,7 @@ class YouAPIOutput(BaseModel):
class YouDocument(BaseModel):
- """The output of parsing one snippet"""
+ """Output of parsing one snippet."""
page_content: str = Field(description="One snippet of text")
metadata: YouHitMetadata
diff --git a/libs/community/langchain_community/utils/ernie_functions.py b/libs/community/langchain_community/utils/ernie_functions.py
index 7fa3580bce..4166de1bfd 100644
--- a/libs/community/langchain_community/utils/ernie_functions.py
+++ b/libs/community/langchain_community/utils/ernie_functions.py
@@ -28,7 +28,7 @@ def convert_pydantic_to_ernie_function(
name: Optional[str] = None,
description: Optional[str] = None,
) -> FunctionDescription:
- """Converts a Pydantic model to a function description for the Ernie API."""
+ """Convert a Pydantic model to a function description for the Ernie API."""
schema = dereference_refs(model.schema())
schema.pop("definitions", None)
return {
@@ -44,7 +44,7 @@ def convert_pydantic_to_ernie_tool(
name: Optional[str] = None,
description: Optional[str] = None,
) -> ToolDescription:
- """Converts a Pydantic model to a function description for the Ernie API."""
+ """Convert a Pydantic model to a function description for the Ernie API."""
function = convert_pydantic_to_ernie_function(
model, name=name, description=description
)
diff --git a/libs/community/langchain_community/utils/google.py b/libs/community/langchain_community/utils/google.py
index 4e68512296..18028c6500 100644
--- a/libs/community/langchain_community/utils/google.py
+++ b/libs/community/langchain_community/utils/google.py
@@ -5,7 +5,7 @@ from typing import Any, Optional
def get_client_info(module: Optional[str] = None) -> Any:
- r"""Returns a custom user agent header.
+ r"""Return a custom user agent header.
Args:
module (Optional[str]):
diff --git a/libs/community/langchain_community/vectorstores/neo4j_vector.py b/libs/community/langchain_community/vectorstores/neo4j_vector.py
index 4fd6cee51d..8cb51d7f2b 100644
--- a/libs/community/langchain_community/vectorstores/neo4j_vector.py
+++ b/libs/community/langchain_community/vectorstores/neo4j_vector.py
@@ -139,7 +139,7 @@ def remove_lucene_chars(text: str) -> str:
def dict_to_yaml_str(input_dict: Dict, indent: int = 0) -> str:
"""
- Converts a dictionary to a YAML-like string without using external libraries.
+ Convert a dictionary to a YAML-like string without using external libraries.
Parameters:
- input_dict (dict): The dictionary to convert.
@@ -165,6 +165,8 @@ def dict_to_yaml_str(input_dict: Dict, indent: int = 0) -> str:
def combine_queries(
input_queries: List[Tuple[str, Dict[str, Any]]], operator: str
) -> Tuple[str, Dict[str, Any]]:
+ """Combine multiple queries with an operator."""
+
# Initialize variables to hold the combined query and parameters
combined_query: str = ""
combined_params: Dict = {}
@@ -197,8 +199,7 @@ def combine_queries(
def collect_params(
input_data: List[Tuple[str, Dict[str, str]]],
) -> Tuple[List[str], Dict[str, Any]]:
- """
- Transform the input data into the desired format.
+ """Transform the input data into the desired format.
Args:
- input_data (list of tuples): Input data to transform.
@@ -324,6 +325,15 @@ def _handle_field_filter(
def construct_metadata_filter(filter: Dict[str, Any]) -> Tuple[str, Dict]:
+ """Construct a metadata filter.
+
+ Args:
+ filter: A dictionary representing the filter condition.
+
+ Returns:
+ Tuple[str, Dict]
+ """
+
if isinstance(filter, dict):
if len(filter) == 1:
# The only operators allowed at the top level are $AND and $OR
diff --git a/libs/community/langchain_community/vectorstores/redis/filters.py b/libs/community/langchain_community/vectorstores/redis/filters.py
index 8ec492ee2c..09a58bd281 100644
--- a/libs/community/langchain_community/vectorstores/redis/filters.py
+++ b/libs/community/langchain_community/vectorstores/redis/filters.py
@@ -100,7 +100,7 @@ def check_operator_misuse(func: Callable) -> Callable:
class RedisTag(RedisFilterField):
- """A RedisFilterField representing a tag in a Redis index."""
+ """RedisFilterField representing a tag in a Redis index."""
OPERATORS: Dict[RedisFilterOperator, str] = {
RedisFilterOperator.EQ: "==",
@@ -192,7 +192,7 @@ class RedisTag(RedisFilterField):
class RedisNum(RedisFilterField):
- """A RedisFilterField representing a numeric field in a Redis index."""
+ """RedisFilterField representing a numeric field in a Redis index."""
OPERATORS: Dict[RedisFilterOperator, str] = {
RedisFilterOperator.EQ: "==",
@@ -311,7 +311,7 @@ class RedisNum(RedisFilterField):
class RedisText(RedisFilterField):
- """A RedisFilterField representing a text field in a Redis index."""
+ """RedisFilterField representing a text field in a Redis index."""
OPERATORS: Dict[RedisFilterOperator, str] = {
RedisFilterOperator.EQ: "==",
@@ -381,7 +381,7 @@ class RedisText(RedisFilterField):
class RedisFilterExpression:
- """A logical expression of RedisFilterFields.
+ """Logical expression of RedisFilterFields.
RedisFilterExpressions can be combined using the & and | operators to create
complex logical expressions that evaluate to the Redis Query language.
diff --git a/libs/community/langchain_community/vectorstores/redis/schema.py b/libs/community/langchain_community/vectorstores/redis/schema.py
index 8269b71f69..5b8618797e 100644
--- a/libs/community/langchain_community/vectorstores/redis/schema.py
+++ b/libs/community/langchain_community/vectorstores/redis/schema.py
@@ -285,7 +285,7 @@ class RedisModel(BaseModel):
def read_schema(
index_schema: Optional[Union[Dict[str, List[Any]], str, os.PathLike]],
) -> Dict[str, Any]:
- """Reads in the index schema from a dict or yaml file.
+ """Read in the index schema from a dict or yaml file.
Check if it is a dict and return RedisModel otherwise, check if it's a path and
read in the file assuming it's a yaml file and return a RedisModel
diff --git a/libs/community/langchain_community/vectorstores/sklearn.py b/libs/community/langchain_community/vectorstores/sklearn.py
index 685e2e28e4..8194e31db6 100644
--- a/libs/community/langchain_community/vectorstores/sklearn.py
+++ b/libs/community/langchain_community/vectorstores/sklearn.py
@@ -42,7 +42,7 @@ class BaseSerializer(ABC):
class JsonSerializer(BaseSerializer):
- """Serializes data in json using the json package from python standard library."""
+ """Serialize data in JSON using the json package from python standard library."""
@classmethod
def extension(cls) -> str:
@@ -58,7 +58,7 @@ class JsonSerializer(BaseSerializer):
class BsonSerializer(BaseSerializer):
- """Serializes data in binary json using the `bson` python package."""
+ """Serialize data in Binary JSON using the `bson` python package."""
def __init__(self, persist_path: str) -> None:
super().__init__(persist_path)
@@ -78,7 +78,7 @@ class BsonSerializer(BaseSerializer):
class ParquetSerializer(BaseSerializer):
- """Serializes data in `Apache Parquet` format using the `pyarrow` package."""
+ """Serialize data in `Apache Parquet` format using the `pyarrow` package."""
def __init__(self, persist_path: str) -> None:
super().__init__(persist_path)
diff --git a/libs/community/langchain_community/vectorstores/sqlitevss.py b/libs/community/langchain_community/vectorstores/sqlitevss.py
index 60551d0206..3ea9f42770 100644
--- a/libs/community/langchain_community/vectorstores/sqlitevss.py
+++ b/libs/community/langchain_community/vectorstores/sqlitevss.py
@@ -24,7 +24,8 @@ logger = logging.getLogger(__name__)
class SQLiteVSS(VectorStore):
- """Wrapper around SQLite with vss extension as a vector database.
+ """SQLite with VSS extension as a vector database.
+
To use, you should have the ``sqlite-vss`` python package installed.
Example:
.. code-block:: python
diff --git a/libs/community/langchain_community/vectorstores/tidb_vector.py b/libs/community/langchain_community/vectorstores/tidb_vector.py
index 958ba7f52d..e98d3bb6c4 100644
--- a/libs/community/langchain_community/vectorstores/tidb_vector.py
+++ b/libs/community/langchain_community/vectorstores/tidb_vector.py
@@ -10,6 +10,8 @@ DEFAULT_TiDB_VECTOR_TABLE_NAME = "langchain_vector"
class TiDBVectorStore(VectorStore):
+ """TiDB Vector Store."""
+
def __init__(
self,
connection_string: str,
diff --git a/libs/community/langchain_community/vectorstores/vald.py b/libs/community/langchain_community/vectorstores/vald.py
index 6b6abae4e9..31102ce0f7 100644
--- a/libs/community/langchain_community/vectorstores/vald.py
+++ b/libs/community/langchain_community/vectorstores/vald.py
@@ -12,7 +12,7 @@ from langchain_community.vectorstores.utils import maximal_marginal_relevance
class Vald(VectorStore):
- """Wrapper around Vald vector database.
+ """Vald vector database.
To use, you should have the ``vald-client-python`` python package installed.
diff --git a/libs/community/langchain_community/vectorstores/vdms.py b/libs/community/langchain_community/vectorstores/vdms.py
index d07c57469b..52de71201b 100644
--- a/libs/community/langchain_community/vectorstores/vdms.py
+++ b/libs/community/langchain_community/vectorstores/vdms.py
@@ -77,8 +77,7 @@ def _len_check_if_sized(x: Any, y: Any, x_name: str, y_name: str) -> None:
def VDMS_Client(host: str = "localhost", port: int = 55555) -> vdms.vdms:
- """
- Wrapper to initiate and connect a VDMS client to a VDMS server
+ """VDMS client for the VDMS server.
Args:
host: IP or hostname of VDMS server
@@ -98,7 +97,7 @@ def VDMS_Client(host: str = "localhost", port: int = 55555) -> vdms.vdms:
class VDMS(VectorStore):
- """Wrapper around Intel Lab's VDMS for vector-store workloads.
+ """Intel Lab's VDMS for vector-store workloads.
To use, you should have both:
- the ``vdms`` python package installed
@@ -1534,6 +1533,8 @@ def _check_descriptor_exists_by_id(
def embedding2bytes(embedding: Union[List[float], None]) -> Union[bytes, None]:
+ """Convert embedding to bytes."""
+
blob = None
if embedding is not None:
emb = np.array(embedding, dtype="float32")
diff --git a/libs/community/langchain_community/vectorstores/vectara.py b/libs/community/langchain_community/vectorstores/vectara.py
index edebc3f413..2c66d38f84 100644
--- a/libs/community/langchain_community/vectorstores/vectara.py
+++ b/libs/community/langchain_community/vectorstores/vectara.py
@@ -18,7 +18,8 @@ logger = logging.getLogger(__name__)
@dataclass
class SummaryConfig:
- """
+ """Configuration for summary generation.
+
is_enabled: True if summary is enabled, False otherwise
max_results: maximum number of results to summarize
response_lang: requested language for the summary
@@ -34,7 +35,8 @@ class SummaryConfig:
@dataclass
class MMRConfig:
- """
+ """Configuration for Maximal Marginal Relevance (MMR) search.
+
is_enabled: True if MMR is enabled, False otherwise
mmr_k: number of results to fetch for MMR, defaults to 50
diversity_bias: number between 0 and 1 that determines the degree
@@ -53,7 +55,8 @@ class MMRConfig:
@dataclass
class VectaraQueryConfig:
- """
+ """Configuration for Vectara query.
+
k: Number of Documents to return. Defaults to 10.
lambda_val: lexical match parameter for hybrid search.
filter Dictionary of argument(s) to filter on metadata. For example a
@@ -566,7 +569,7 @@ class Vectara(VectorStore):
class VectaraRetriever(VectorStoreRetriever):
- """Retriever class for `Vectara`."""
+ """Retriever for `Vectara`."""
vectorstore: Vectara
"""Vectara vectorstore."""
diff --git a/libs/community/langchain_community/vectorstores/yellowbrick.py b/libs/community/langchain_community/vectorstores/yellowbrick.py
index d7f1a159f3..e3e5504346 100644
--- a/libs/community/langchain_community/vectorstores/yellowbrick.py
+++ b/libs/community/langchain_community/vectorstores/yellowbrick.py
@@ -23,7 +23,8 @@ logger = logging.getLogger(__name__)
class Yellowbrick(VectorStore):
- """Wrapper around Yellowbrick as a vector database.
+ """Yellowbrick as a vector database.
+
Example:
.. code-block:: python
from langchain_community.vectorstores import Yellowbrick