Google PaLM API in Discord.
Discord only can handle 2000 characters per message, so I manually set the PaLM can only outputting no more than 145 tokens. If your channel can handle 4000 or even more, make the output_token_limit= 145
in main.py
value doubled or more.
/palm
to chat with PaLM.
- Go Discord Dev
- Go
Application
on the left part - Go
New Application
, create a new Bot - Go
Bot
on the left - Click
Add bot
- Turn on
MESSAGE CONTENT INTENT
Save Change
- View and save your API Key on the top of page
View Token
, or reset one if you don't remember - Click OAuth2 on the left part
- Click on
URL Generator
- Choose
bot
inSCOPES
,Administrator
inBOT PERMISSIONS
- Copy the link at bottom into your browser, add bot and authorize to you server.
Go to MakerSuite, and create an API key for this application.
- git clone this repository
pip install discord google-generativeai
cd PaLM-Discord-Bot
notepad main.py
- replace with your Discord API Key and PaLM API Key at following lines:
palm.configure(api_key = "PaLM_API_KEY")
client.run("DISCORD_TOKEN")
python main.py
https://discordpy.readthedocs.io/en/stable/#getting-started
https://developers.generativeai.google/api/python/google/generativeai