DiscordRetrieveTool - AG2

DiscordRetrieveTool

autogen.tools.experimental.DiscordRetrieveTool

DiscordRetrieveTool(*, bot_token, channel_name, guild_name)

Bases: Tool

Retrieves messages from a Discord channel.

Initialize the DiscordRetrieveTool.

PARAMETER DESCRIPTION
bot_token The bot token to use for retrieving messages.
TYPE:str
channel_name The name of the channel to retrieve messages from.
TYPE:str
guild_name The name of the guild for the channel.
TYPE:str

Source code in autogen/tools/experimental/messageplatform/discord/discord.py

    def __init__(self, *, bot_token: str, channel_name: str, guild_name: str) -> None:
        """
        Initialize the DiscordRetrieveTool.
        Args:
            bot_token: The bot token to use for retrieving messages.
            channel_name: The name of the channel to retrieve messages from.
            guild_name: The name of the guild for the channel.
        """
        async def discord_retrieve_messages(
            bot_token: str,
            guild_name: str,
            channel_name: str,
            messages_since: Union[str, None] = None,
            maximum_messages: Union[int, None] = None,
        ) -> Any:
            """
            Retrieves messages from a Discord channel.
            Args:
                bot_token: The bot token to use for Discord.
                guild_name: The name of the server.
                channel_name: The name of the channel.
                messages_since: ISO format date string OR Discord snowflake ID.
                maximum_messages: Maximum number of messages to retrieve.
            """
            # ... function implementation ...
        
    super().__init__(
        name="discord_retrieve",
        description="Retrieves messages from a Discord channel based datetime/message ID and/or number of latest messages.",
        func_or_tool=discord_retrieve_messages,
    )

name property

name

description property

description

func property

func

tool_schema property

tool_schema

Get the schema for the tool.

function_schema property

function_schema

Get the schema for the function.

realtime_tool_schema property

realtime_tool_schema

Get the schema for the tool.

register_for_llm

register_for_llm(agent)

Registers the tool for use with a ConversableAgent's language model (LLM).

PARAMETER DESCRIPTION
agent The agent to which the tool will be registered.
TYPE:ConversableAgent

Source code in autogen/tools/tool.py

    def register_for_llm(self, agent: "ConversableAgent") -> None:
        """Registers the tool for use with a ConversableAgent's language model (LLM).
        Args:
            agent (ConversableAgent): The agent to which the tool will be registered.
        """
        agent.register_for_llm()(self)

register_for_execution

register_for_execution(agent)

Registers the tool for direct execution by a ConversableAgent.

PARAMETER DESCRIPTION
agent The agent to which the tool will be registered.
TYPE:ConversableAgent

Source code in autogen/tools/tool.py

    def register_for_execution(self, agent: "ConversableAgent") -> None:
        """Registers the tool for direct execution by a ConversableAgent.
        Args:
            agent (ConversableAgent): The agent to which the tool will be registered.
        """
        agent.register_for_execution()(self)

register_tool

register_tool(agent)

Register a tool to be both proposed and executed by an agent.

PARAMETER DESCRIPTION
agent The agent to which the tool will be registered.
TYPE:ConversableAgent

Source code in autogen/tools/tool.py

    def register_tool(self, agent: "ConversableAgent") -> None:
        """Register a tool to be both proposed and executed by an agent.
        Args:
            agent (ConversableAgent): The agent to which the tool will be registered.
        """
        self.register_for_llm(agent)
        self.register_for_execution(agent)