From ff1c6de86c0d37627f19ad6d59b6064c19ddf4dc Mon Sep 17 00:00:00 2001 From: "mateusz.wosinski" Date: Thu, 7 Sep 2023 19:56:53 +0200 Subject: [PATCH] TYPE_CHECKING added --- .../langchain/tools/eleven_labs/text2speech.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/langchain/langchain/tools/eleven_labs/text2speech.py b/libs/langchain/langchain/tools/eleven_labs/text2speech.py index 16deff41f4..def4c8084b 100644 --- a/libs/langchain/langchain/tools/eleven_labs/text2speech.py +++ b/libs/langchain/langchain/tools/eleven_labs/text2speech.py @@ -1,5 +1,5 @@ import tempfile -from typing import Dict, Optional, Union +from typing import Dict, Optional, Union, TYPE_CHECKING from langchain.callbacks.manager import CallbackManagerForToolRun from langchain.pydantic_v1 import root_validator @@ -7,13 +7,14 @@ from langchain.tools.base import BaseTool from langchain.tools.eleven_labs.models import ElevenLabsModel from langchain.utils import get_from_dict_or_env -try: - import elevenlabs +if TYPE_CHECKING: + try: + import elevenlabs -except ImportError: - raise ImportError( - "elevenlabs is not installed. " "Run `pip install elevenlabs` to install." - ) + except ImportError: + raise ImportError( + "elevenlabs is not installed. " "Run `pip install elevenlabs` to install." + ) class ElevenLabsText2SpeechTool(BaseTool):