Discord Bot with Cloudflare AI
Luis
Posted on April 13, 2024
This is a submission for the Cloudflare AI Challenge.
What I Built
Discord Bot for asking questions to AI or generating images
Demo
Discord Bot: https://discord.com/oauth2/authorize?client_id=1227951760539258880&permissions=0&scope=bot
My Code
Repository: https://github.com/LuisFun/discord-bot-cloudflare-ai-challenge
Journey
I realized that most of the projects that have been submitted so far were in the form of websites, as we are in the latter half of the challenge period.
Therefore, as a different approach, I tried creating a simple application using a discord bot.
The main thing I worked on during the challenge period was creating and publishing a plugin package.
Stacks
- Cloudflare
- Discord Bot
-
discord-hono
(I made it) -
@luisfun/cloudflare-ai-plugin
(I made it)
@luisfun/cloudflare-ai-plugin
can do the following:
- AI Gateway - You can code the AI Gateway in the same way as the workers AI.
- MD Translator - You can translate while maintaining the structure of Markdown to some extent.
By using the module and plugin that I created, the server code for the Bot was 80 lines, and the command registration code for the Bot was 50 lines. In this way, I was able to create a Bot with such a small amount of code.
Multiple Models and/or Triple Task Types
All Text Generation models
All Text to Image models
@cf/meta/m2m100-1.2b
If the language set in the discord is not English, the default behavior is to process as follows
Translate prompt
-> Generate text or image
(-> Translate text
)
In the second translation, I made sure not to break the markdown format.
Posted on April 13, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.