Skip to content

Commit efc687a

Browse files
authored
community[patch]: fix instantiation for Slack tools (#28990)
Believe the current implementation raises PydanticUserError following [this](https://github.com/pydantic/pydantic/releases/tag/v2.10.1) Pydantic release. Resolves #28989
1 parent c59093d commit efc687a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

libs/community/langchain_community/agent_toolkits/slack/toolkit.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
from langchain_community.tools.slack.utils import login
1414

1515
if TYPE_CHECKING:
16+
# This is for linting and IDE typehints
1617
from slack_sdk import WebClient
18+
else:
19+
try:
20+
# We do this so pydantic can resolve the types when instantiating
21+
from slack_sdk import WebClient
22+
except ImportError:
23+
pass
1724

1825

1926
class SlackToolkit(BaseToolkit):

libs/community/langchain_community/tools/slack/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
from langchain_community.tools.slack.utils import login
1111

1212
if TYPE_CHECKING:
13+
# This is for linting and IDE typehints
1314
from slack_sdk import WebClient
15+
else:
16+
try:
17+
# We do this so pydantic can resolve the types when instantiating
18+
from slack_sdk import WebClient
19+
except ImportError:
20+
pass
1421

1522

1623
class SlackBaseTool(BaseTool): # type: ignore[override]

0 commit comments

Comments
 (0)