mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-04 04:07:54 +00:00
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
28 lines
679 B
Python
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."""
|