Skip to content

The agent engineering platform.

community[patch]: Add missing type annotations (#22758)

Eugene Yurtsev05d31a2f0039
diff --git a/libs/community/langchain_community/callbacks/upstash_ratelimit_callback.py b/libs/community/langchain_community/callbacks/upstash_ratelimit_callback.py
index 9bd984be4f..068bf9dc05 100644
--- a/libs/community/langchain_community/callbacks/upstash_ratelimit_callback.py
+++ b/libs/community/langchain_community/callbacks/upstash_ratelimit_callback.py
@@ -59,7 +59,7 @@ class UpstashRatelimitHandler(BaseCallbackHandler):
"""
raise_error = True
- _checked = False
+ _checked: bool = False
def __init__(
self,
diff --git a/libs/community/langchain_community/chains/pebblo_retrieval/base.py b/libs/community/langchain_community/chains/pebblo_retrieval/base.py
index e5ecb0f525..2be7dd6878 100644
--- a/libs/community/langchain_community/chains/pebblo_retrieval/base.py
+++ b/libs/community/langchain_community/chains/pebblo_retrieval/base.py
@@ -72,9 +72,9 @@ class PebbloRetrievalQA(Chain):
"""Pebblo cloud API key for app."""
classifier_url: str = CLASSIFIER_URL #: :meta private:
"""Classifier endpoint."""
- _discover_sent = False #: :meta private:
+ _discover_sent: bool = False #: :meta private:
"""Flag to check if discover payload has been sent."""
- _prompt_sent = False #: :meta private:
+ _prompt_sent: bool = False #: :meta private:
"""Flag to check if prompt payload has been sent."""
def _call(
diff --git a/libs/community/langchain_community/chat_models/baichuan.py b/libs/community/langchain_community/chat_models/baichuan.py
index 41e8de826c..e881b36abb 100644
--- a/libs/community/langchain_community/chat_models/baichuan.py
+++ b/libs/community/langchain_community/chat_models/baichuan.py
@@ -97,7 +97,7 @@ class ChatBaichuan(BaseChatModel):
"""Whether to stream the results or not."""
request_timeout: int = Field(default=60, alias="timeout")
"""request timeout for chat http requests"""
- model = "Baichuan2-Turbo-192K"
+ model: str = "Baichuan2-Turbo-192K"
"""model name of Baichuan, default is `Baichuan2-Turbo-192K`,
other options include `Baichuan2-Turbo`"""
temperature: Optional[float] = Field(default=0.3)
diff --git a/libs/community/langchain_community/llms/oci_data_science_model_deployment_endpoint.py b/libs/community/langchain_community/llms/oci_data_science_model_deployment_endpoint.py
index 9092f06779..acd4ff5e11 100644
--- a/libs/community/langchain_community/llms/oci_data_science_model_deployment_endpoint.py
+++ b/libs/community/langchain_community/llms/oci_data_science_model_deployment_endpoint.py
@@ -240,7 +240,7 @@ class OCIModelDeploymentTGI(OCIModelDeploymentLLM):
sampling and Top-p sampling.
"""
- watermark = True
+ watermark: bool = True
"""Watermarking with `A Watermark for Large Language Models <https://arxiv.org/abs/2301.10226>`_.
Defaults to True."""
diff --git a/libs/community/langchain_community/retrievers/breebs.py b/libs/community/langchain_community/retrievers/breebs.py
index b9238db5b1..b6551b090b 100644
--- a/libs/community/langchain_community/retrievers/breebs.py
+++ b/libs/community/langchain_community/retrievers/breebs.py
@@ -18,7 +18,7 @@ class BreebsRetriever(BaseRetriever):
"""
breeb_key: str
- url = "https://breebs.promptbreeders.com/knowledge"
+ url: str = "https://breebs.promptbreeders.com/knowledge"
def __init__(self, breeb_key: str):
super().__init__(breeb_key=breeb_key) # type: ignore[call-arg]
diff --git a/libs/community/langchain_community/tools/audio/huggingface_text_to_speech_inference.py b/libs/community/langchain_community/tools/audio/huggingface_text_to_speech_inference.py
index 9c16b08d1b..62d73f9191 100644
--- a/libs/community/langchain_community/tools/audio/huggingface_text_to_speech_inference.py
+++ b/libs/community/langchain_community/tools/audio/huggingface_text_to_speech_inference.py
@@ -37,8 +37,8 @@ class HuggingFaceTextToSpeechModelInference(BaseTool):
api_url: str
huggingface_api_key: SecretStr
- _HUGGINGFACE_API_KEY_ENV_NAME = "HUGGINGFACE_API_KEY"
- _HUGGINGFACE_API_URL_ROOT = "https://api-inference.huggingface.co/models"
+ _HUGGINGFACE_API_KEY_ENV_NAME: str = "HUGGINGFACE_API_KEY"
+ _HUGGINGFACE_API_URL_ROOT: str = "https://api-inference.huggingface.co/models"
def __init__(
self,
diff --git a/libs/community/langchain_community/tools/cogniswitch/tool.py b/libs/community/langchain_community/tools/cogniswitch/tool.py
index 514b3b97b1..d88120e507 100644
--- a/libs/community/langchain_community/tools/cogniswitch/tool.py
+++ b/libs/community/langchain_community/tools/cogniswitch/tool.py
@@ -24,7 +24,7 @@ class CogniswitchKnowledgeRequest(BaseTool):
cs_token: str
OAI_token: str
apiKey: str
- api_url = "https://api.cogniswitch.ai:8243/cs-api/0.0.1/cs/knowledgeRequest"
+ api_url: str = "https://api.cogniswitch.ai:8243/cs-api/0.0.1/cs/knowledgeRequest"
def _run(
self,
diff --git a/libs/community/langchain_community/tools/e2b_data_analysis/tool.py b/libs/community/langchain_community/tools/e2b_data_analysis/tool.py
index 242b305e1b..6de115e0b4 100644
--- a/libs/community/langchain_community/tools/e2b_data_analysis/tool.py
+++ b/libs/community/langchain_community/tools/e2b_data_analysis/tool.py
@@ -96,7 +96,7 @@ class E2BDataAnalysisToolArguments(BaseModel):
class E2BDataAnalysisTool(BaseTool):
"""Tool for running python code in a sandboxed environment for data analysis."""
- name = "e2b_data_analysis"
+ name: str = "e2b_data_analysis"
args_schema: Type[BaseModel] = E2BDataAnalysisToolArguments
session: Any
description: str
diff --git a/libs/community/langchain_community/tools/edenai/audio_speech_to_text.py b/libs/community/langchain_community/tools/edenai/audio_speech_to_text.py
index 00f158ed53..ba2978399a 100644
--- a/libs/community/langchain_community/tools/edenai/audio_speech_to_text.py
+++ b/libs/community/langchain_community/tools/edenai/audio_speech_to_text.py
@@ -28,13 +28,13 @@ class EdenAiSpeechToTextTool(EdenaiTool):
edenai_api_key: Optional[str] = None
- name = "edenai_speech_to_text"
+ name: str = "edenai_speech_to_text"
description = (
"A wrapper around edenai Services speech to text "
"Useful for when you have to convert audio to text."
"Input should be a url to an audio file."
)
- is_async = True
+ is_async: bool = True
language: Optional[str] = "en"
speakers: Optional[int]
@@ -43,7 +43,7 @@ class EdenAiSpeechToTextTool(EdenaiTool):
feature: str = "audio"
subfeature: str = "speech_to_text_async"
- base_url = "https://api.edenai.run/v2/audio/speech_to_text_async/"
+ base_url: str = "https://api.edenai.run/v2/audio/speech_to_text_async/"
@validator("providers")
def check_only_one_provider_selected(cls, v: List[str]) -> List[str]:
diff --git a/libs/community/langchain_community/tools/edenai/audio_text_to_speech.py b/libs/community/langchain_community/tools/edenai/audio_text_to_speech.py
index 575b9a70b5..fad670e0f3 100644
--- a/libs/community/langchain_community/tools/edenai/audio_text_to_speech.py
+++ b/libs/community/langchain_community/tools/edenai/audio_text_to_speech.py
@@ -23,7 +23,7 @@ class EdenAiTextToSpeechTool(EdenaiTool):
"""
- name = "edenai_text_to_speech"
+ name: str = "edenai_text_to_speech"
description = (
"A wrapper around edenai Services text to speech."
"Useful for when you need to convert text to speech."
diff --git a/libs/community/langchain_community/tools/edenai/image_explicitcontent.py b/libs/community/langchain_community/tools/edenai/image_explicitcontent.py
index fbeb4c1ec1..84012bff6b 100644
--- a/libs/community/langchain_community/tools/edenai/image_explicitcontent.py
+++ b/libs/community/langchain_community/tools/edenai/image_explicitcontent.py
@@ -23,9 +23,9 @@ class EdenAiExplicitImageTool(EdenaiTool):
"""
- name = "edenai_image_explicit_content_detection"
+ name: str = "edenai_image_explicit_content_detection"
- description = (
+ description: str = (
"A wrapper around edenai Services Explicit image detection. "
"""Useful for when you have to extract Explicit Content from images.
it detects adult only content in images,
@@ -35,9 +35,9 @@ class EdenAiExplicitImageTool(EdenaiTool):
"Input should be the string url of the image ."
)
- combine_available = True
- feature = "image"
- subfeature = "explicit_content"
+ combine_available: bool = True
+ feature: str = "image"
+ subfeature: str = "explicit_content"
def _parse_json(self, json_data: dict) -> str:
result_str = f"nsfw_likelihood: {json_data['nsfw_likelihood']}\n"
diff --git a/libs/community/langchain_community/tools/edenai/image_objectdetection.py b/libs/community/langchain_community/tools/edenai/image_objectdetection.py
index e40d464d5c..03b9fc36e5 100644
--- a/libs/community/langchain_community/tools/edenai/image_objectdetection.py
+++ b/libs/community/langchain_community/tools/edenai/image_objectdetection.py
@@ -22,9 +22,9 @@ class EdenAiObjectDetectionTool(EdenaiTool):
"""
- name = "edenai_object_detection"
+ name: str = "edenai_object_detection"
- description = (
+ description: str = (
"A wrapper around edenai Services Object Detection . "
"""Useful for when you have to do an to identify and locate
(with bounding boxes) objects in an image """
@@ -33,8 +33,8 @@ class EdenAiObjectDetectionTool(EdenaiTool):
show_positions: bool = False
- feature = "image"
- subfeature = "object_detection"
+ feature: str = "image"
+ subfeature: str = "object_detection"
def _parse_json(self, json_data: dict) -> str:
result = []
diff --git a/libs/community/langchain_community/tools/edenai/ocr_identityparser.py b/libs/community/langchain_community/tools/edenai/ocr_identityparser.py
index 6af27c92fd..75352312e5 100644
--- a/libs/community/langchain_community/tools/edenai/ocr_identityparser.py
+++ b/libs/community/langchain_community/tools/edenai/ocr_identityparser.py
@@ -22,16 +22,16 @@ class EdenAiParsingIDTool(EdenaiTool):
"""
- name = "edenai_identity_parsing"
+ name: str = "edenai_identity_parsing"
- description = (
+ description: str = (
"A wrapper around edenai Services Identity parsing. "
"Useful for when you have to extract information from an ID Document "
"Input should be the string url of the document to parse."
)
- feature = "ocr"
- subfeature = "identity_parser"
+ feature: str = "ocr"
+ subfeature: str = "identity_parser"
language: Optional[str] = None
"""
diff --git a/libs/community/langchain_community/tools/edenai/ocr_invoiceparser.py b/libs/community/langchain_community/tools/edenai/ocr_invoiceparser.py
index 6b2e7d8bef..4413beedf7 100644
--- a/libs/community/langchain_community/tools/edenai/ocr_invoiceparser.py
+++ b/libs/community/langchain_community/tools/edenai/ocr_invoiceparser.py
@@ -22,9 +22,9 @@ class EdenAiParsingInvoiceTool(EdenaiTool):
"""
- name = "edenai_invoice_parsing"
+ name: str = "edenai_invoice_parsing"
- description = (
+ description: str = (
"A wrapper around edenai Services invoice parsing. "
"""Useful for when you have to extract information from
an image it enables to take invoices
@@ -39,8 +39,8 @@ class EdenAiParsingInvoiceTool(EdenaiTool):
language of the image passed to the model.
"""
- feature = "ocr"
- subfeature = "invoice_parser"
+ feature: str = "ocr"
+ subfeature: str = "invoice_parser"
def _parse_response(self, response: list) -> str:
formatted_list: list = []
diff --git a/libs/community/langchain_community/tools/edenai/text_moderation.py b/libs/community/langchain_community/tools/edenai/text_moderation.py
index 44d1308117..2486287fba 100644
--- a/libs/community/langchain_community/tools/edenai/text_moderation.py
+++ b/libs/community/langchain_community/tools/edenai/text_moderation.py
@@ -22,9 +22,9 @@ class EdenAiTextModerationTool(EdenaiTool):
"""
- name = "edenai_explicit_content_detection_text"
+ name: str = "edenai_explicit_content_detection_text"
- description = (
+ description: str = (
"A wrapper around edenai Services explicit content detection for text. "
"""Useful for when you have to scan text for offensive,
sexually explicit or suggestive content,
diff --git a/libs/community/langchain_community/tools/you/tool.py b/libs/community/langchain_community/tools/you/tool.py
index 75b06bd013..949eca0827 100644
--- a/libs/community/langchain_community/tools/you/tool.py
+++ b/libs/community/langchain_community/tools/you/tool.py
@@ -20,8 +20,8 @@ class YouInput(BaseModel):
class YouSearchTool(BaseTool):
"""Tool that searches the you.com API."""
- name = "you_search"
- description = (
+ name: str = "you_search"
+ description: str = (
"The YOU APIs make LLMs and search experiences more factual and"
"up to date with realtime web data."
)
diff --git a/libs/community/langchain_community/utilities/mojeek_search.py b/libs/community/langchain_community/utilities/mojeek_search.py
index 4b4a767022..8f48059dcb 100644
--- a/libs/community/langchain_community/utilities/mojeek_search.py
+++ b/libs/community/langchain_community/utilities/mojeek_search.py
@@ -8,7 +8,7 @@ from langchain_core.pydantic_v1 import BaseModel, Field
class MojeekSearchAPIWrapper(BaseModel):
api_key: str
search_kwargs: dict = Field(default_factory=dict)
- api_url = "https://api.mojeek.com/search"
+ api_url: str = "https://api.mojeek.com/search"
def run(self, query: str) -> str:
search_results = self._search(query)
diff --git a/libs/community/tests/integration_tests/llms/test_bedrock.py b/libs/community/tests/integration_tests/llms/test_bedrock.py
index 98d02ad3a3..07dc1ce180 100644
--- a/libs/community/tests/integration_tests/llms/test_bedrock.py
+++ b/libs/community/tests/integration_tests/llms/test_bedrock.py
@@ -26,7 +26,7 @@ GUARDRAILS_TRIGGER = os.environ.get(
class BedrockAsyncCallbackHandler(AsyncCallbackHandler):
"""Async callback handler that can be used to handle callbacks from langchain."""
- guardrails_intervened = False
+ guardrails_intervened: bool = False
async def on_llm_error(
self,