Google PaLM API in Discord.
Google PaLM API only works in the United States.
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.
Also, I dropped the temperature option, you can always add it back.
- Adapt the latest Google Vertex AI platform for Gemini(pro)
- Use .env instead
- Integrate this with any other AIGC APIs and make this more versatile?
/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.
- Join the waitlist here, after you passed the waitlist, you'll receive an email like this:
- Go MakerSuite, and create an API key for this application.
- Star this project I guess
- git clone this repository
pip install discord google-generativeai
cd PaLM-Discord-Bot
nano 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")
python3 main.py
If you want to run it background, you can try Screen.
Huge thanks to following projects.
https://github.com/TheExplainthis/ChatGPT-Discord-Bot
https://discordpy.readthedocs.io/en/stable/#getting-started
https://developers.generativeai.google/api/python/google/generativeai
This work is under MIT License.