o
    ZhG                     @  s   d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ erId dlmZ nzd dlmZ W n	 eyZ   Y nw G dd deZdS )    )annotations)TYPE_CHECKINGList)BaseTool)BaseToolkit)
ConfigDictField)SlackGetChannel)SlackGetMessage)SlackScheduleMessage)SlackSendMessage)login)	WebClientc                   @  s8   e Zd ZU dZeedZded< eddZ	dd	d
Z
dS )SlackToolkitaW	  Toolkit for interacting with Slack.

    Parameters:
        client: The Slack client.

    Setup:
        Install ``slack_sdk`` and set environment variable ``SLACK_USER_TOKEN``.

        .. code-block:: bash

            pip install -U slack_sdk
            export SLACK_USER_TOKEN="your-user-token"

    Key init args:
        client: slack_sdk.WebClient
            The Slack client.

    Instantiate:
        .. code-block:: python

            from langchain_community.agent_toolkits import SlackToolkit

            toolkit = SlackToolkit()

    Tools:
        .. code-block:: python

            tools = toolkit.get_tools()
            tools

        .. code-block:: none

            [SlackGetChannel(client=<slack_sdk.web.client.WebClient object at 0x113caa8c0>),
            SlackGetMessage(client=<slack_sdk.web.client.WebClient object at 0x113caa4d0>),
            SlackScheduleMessage(client=<slack_sdk.web.client.WebClient object at 0x113caa440>),
            SlackSendMessage(client=<slack_sdk.web.client.WebClient object at 0x113caa410>)]

    Use within an agent:
        .. code-block:: python

            from langchain_openai import ChatOpenAI
            from langgraph.prebuilt import create_react_agent

            llm = ChatOpenAI(model="gpt-4o-mini")
            agent_executor = create_react_agent(llm, tools)

            example_query = "When was the #general channel created?"

            events = agent_executor.stream(
                {"messages": [("user", example_query)]},
                stream_mode="values",
            )
            for event in events:
                message = event["messages"][-1]
                if message.type != "tool":  # mask sensitive information
                    event["messages"][-1].pretty_print()

        .. code-block:: none

             ================================[1m Human Message [0m=================================

            When was the #general channel created?
            ==================================[1m Ai Message [0m==================================
            Tool Calls:
            get_channelid_name_dict (call_NXDkALjoOx97uF1v0CoZTqtJ)
            Call ID: call_NXDkALjoOx97uF1v0CoZTqtJ
            Args:
            ==================================[1m Ai Message [0m==================================

            The #general channel was created on timestamp 1671043305.
    )default_factoryr   clientT)Zarbitrary_types_allowedreturnList[BaseTool]c                 C  s   t  t t t gS )zGet the tools in the toolkit.)r	   r
   r   r   )self r   g/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/agent_toolkits/slack/toolkit.py	get_toolsi   s
   zSlackToolkit.get_toolsN)r   r   )__name__
__module____qualname____doc__r   r   r   __annotations__r   Zmodel_configr   r   r   r   r   r      s   
 Hr   N)
__future__r   typingr   r   Zlangchain_core.toolsr   Zlangchain_core.tools.baser   Zpydanticr   r   Z+langchain_community.tools.slack.get_channelr	   Z+langchain_community.tools.slack.get_messager
   Z0langchain_community.tools.slack.schedule_messager   Z,langchain_community.tools.slack.send_messager   Z%langchain_community.tools.slack.utilsr   Z	slack_sdkr   ImportErrorr   r   r   r   r   <module>   s$    