Discord Reader
Demonstrates our Discord data connector
If youโre opening this Notebook on colab, you will probably need to install LlamaIndex ๐ฆ.
%pip install llama-index-readers-discord!pip install llama-indeximport loggingimport sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))# This is due to the fact that we use asyncio.loop_until_complete in# the DiscordReader. Since the Jupyter kernel itself runs on# an event loop, we need to add some help with nesting!pip install nest_asyncioimport nest_asyncio
nest_asyncio.apply()from llama_index.core import SummaryIndexfrom llama_index.readers.discord import DiscordReaderfrom IPython.display import Markdown, displayimport osdiscord_token = os.getenv("DISCORD_TOKEN")channel_ids = [1057178784895348746] # Replace with your channel_iddocuments = DiscordReader(discord_token=discord_token).load_data( channel_ids=channel_ids)index = SummaryIndex.from_documents(documents)# set Logging to DEBUG for more detailed outputsquery_engine = index.as_query_engine()response = query_engine.query("<query_text>")display(Markdown(f"<b>{response}</b>"))