mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-05 20:58:25 +00:00
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:
parent
c59093d67f
commit
efc687a13b
@ -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):
|
||||||
|
@ -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]
|
||||||
|
Loading…
Reference in New Issue
Block a user