Skip to content

Commit

Permalink
community[patch]: fix instantiation for Slack tools (langchain-ai#28990)
Browse files Browse the repository at this point in the history
Believe the current implementation raises PydanticUserError following
[this](https://github.com/pydantic/pydantic/releases/tag/v2.10.1)
Pydantic release.

Resolves langchain-ai#28989
  • Loading branch information
ccurme authored and pprados committed Jan 3, 2025
1 parent 224a6e9 commit 4f3025d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
from langchain_community.tools.slack.utils import login

if TYPE_CHECKING:
# This is for linting and IDE typehints
from slack_sdk import WebClient
else:
try:
# We do this so pydantic can resolve the types when instantiating
from slack_sdk import WebClient
except ImportError:
pass


class SlackToolkit(BaseToolkit):
Expand Down
7 changes: 7 additions & 0 deletions libs/community/langchain_community/tools/slack/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
from langchain_community.tools.slack.utils import login

if TYPE_CHECKING:
# This is for linting and IDE typehints
from slack_sdk import WebClient
else:
try:
# We do this so pydantic can resolve the types when instantiating
from slack_sdk import WebClient
except ImportError:
pass


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

0 comments on commit 4f3025d

Please sign in to comment.