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 https://github.com/langchain-ai/langchain/issues/28989
This commit is contained in:
ccurme 2025-01-02 11:14:17 -05:00 committed by GitHub
parent c59093d67f
commit efc687a13b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -13,7 +13,14 @@ from langchain_community.tools.slack.send_message import SlackSendMessage
from langchain_community.tools.slack.utils import login from langchain_community.tools.slack.utils import login
if TYPE_CHECKING: if TYPE_CHECKING:
# This is for linting and IDE typehints
from slack_sdk import WebClient 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): class SlackToolkit(BaseToolkit):

View File

@ -10,7 +10,14 @@ from pydantic import Field
from langchain_community.tools.slack.utils import login from langchain_community.tools.slack.utils import login
if TYPE_CHECKING: if TYPE_CHECKING:
# This is for linting and IDE typehints
from slack_sdk import WebClient 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] class SlackBaseTool(BaseTool): # type: ignore[override]