本页还没有译文
本页 13 段还没译成日本語,下面显示的是英文原文。Discord integrations
还没翻译译自英文(docs.langchain.com)本页 13 段都还没译
Discord is an instant messaging, voice, and video communication platform widely used by communities of all types.
Installation and setup
Install the langchain-discord-shikenso package:
pipuv
pip install langchain-discord-shikensouv add langchain-discord-shikensoYou must provide a bot token via environment variable so the tools can authenticate with the Discord API:
export DISCORD_BOT_TOKEN="your-discord-bot-token"If DISCORD_BOT_TOKEN is not set, the tools will raise a ValueError when instantiated.
Tools
Below is a snippet showing how you can read and send messages in Discord. For more details, see the documentation for Discord tools.
from langchain_discord.tools.discord_read_messages import DiscordReadMessages
from langchain_discord.tools.discord_send_messages import DiscordSendMessage
# Create tool instances
read_tool = DiscordReadMessages()
send_tool = DiscordSendMessage()
# Example: Read the last 3 messages from channel 1234567890
read_result = read_tool({"channel_id": "1234567890", "limit": 3})
print(read_result)
# Example: Send a message to channel 1234567890
send_result = send_tool({"channel_id": "1234567890", "message": "Hello from Markdown example!"})
print(send_result)Toolkit
DiscordToolkit groups multiple Discord-related tools into a single interface. For a usage example, see the Discord toolkit docs.
from langchain_discord.toolkits import DiscordToolkit
toolkit = DiscordToolkit()
tools = toolkit.get_tools()
read_tool = tools[0] # DiscordReadMessages
send_tool = tools[1] # DiscordSendMessageFuture integrations
Additional integrations (e.g., document loaders, chat loaders) could be added for Discord. Check the Discord Developer Docs for more information, and watch for updates or advanced usage examples in the langchain_discord GitHub repo.