Files
langchain/libs/community/langchain_community/tools/slack/base.py
ccurme efc687a13b 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
2025-01-02 16:14:17 +00:00

28 lines
679 B
Python

"""Base class for Slack tools."""
from __future__ import annotations
from typing import TYPE_CHECKING
from langchain_core.tools import BaseTool
from pydantic import Field
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]
"""Base class for Slack tools."""
client: WebClient = Field(default_factory=login)
"""The WebClient object."""