https://github.com/electronic-mango/openai-dalle-telegram-bot
Telegram bot for your DALL·E needs.
https://github.com/electronic-mango/openai-dalle-telegram-bot
dall-e dalle openai openai-api python python-telegram-bot python3 telegram
Last synced: 3 months ago
JSON representation
Telegram bot for your DALL·E needs.
- Host: GitHub
- URL: https://github.com/electronic-mango/openai-dalle-telegram-bot
- Owner: Electronic-Mango
- License: gpl-3.0
- Created: 2024-04-08T19:29:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-15T15:00:09.000Z (about 1 year ago)
- Last Synced: 2024-06-16T14:49:47.003Z (about 1 year ago)
- Topics: dall-e, dalle, openai, openai-api, python, python-telegram-bot, python3, telegram
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple OpenAI image model Telegram bot
A simple and unofficial Telegram bot wrapping [OpenAI API](https://openai.com/blog/openai-api/) image models (like [DALL·E](https://openai.com/dall-e-3)), build with [`python-telegram-bot`](https://github.com/python-telegram-bot/python-telegram-bot)!
Just send a prompt and the bot will respond with a generated image!
## Requirements
This bot was built with `Python 3.12`, [`python-telegram-bot`](https://github.com/python-telegram-bot/python-telegram-bot) and [`openai-python`](https://github.com/openai/openai-python).
Full list of Python requirements is in the `requirements.txt` file, you can use it to install all of them.## Configuration
Configuration is done through a `.env` file. You can copy example file `.env.example` as `.env` and fill required parameters.
```commandline
cp .env.example .env
```### Telegram bot
Only required parameter is a [bot token](https://core.telegram.org/bots#creating-a-new-bot).
You can also restrict who can access the bot via `ALLOWED_USERNAMES`.
You can specify multiple usernames delimited by space.
If you don't want to restrict the bot at all you can remove this parameter or leave it empty.### OpenAI API
There are two required parameters - [API key](https://platform.openai.com/account/api-keys) and [used model](https://platform.openai.com/docs/models/dall-e).
```dotenv
OPENAI_TOKEN=''
OPENAI_MODEL='dall-e-3 or dall-e-2'
```Through `.env` you can also configure level of logging of OpenAI API through `OPENAI_LOG` parameter.
You can set it to `debug` or `info`.
```dotenv
OPENAI_LOG='debug or info'
```## Commands
* `/again` - generates new image for last received prompt
* `/start` or `/help` - prints a simple start message## Running the bot
You can run the bot from the source code directly, or in a Docker container.
### From source code
1. Create a Telegram bot via [BotFather](https://core.telegram.org/bots#6-botfather)
2. Create [OpenAI API key](https://platform.openai.com/account/api-keys)
3. Install all packages from `requirements.txt`
4. Fill `.env` file
5. Run `main.py` file with Python### Docker
1. Create a Telegram bot via [BotFather](https://core.telegram.org/bots#6-botfather)
2. Create [OpenAI API key](https://platform.openai.com/account/api-keys)
3. Fill `.env` file
4. Run `docker compose up -d --build` in terminalNote that `.env` file is used only for loading environment variables into Docker container through compose.
The file itself isn't added to the container.## Disclaimer
This bot is in no way affiliated, associated, authorized, endorsed by, or in any way officially connected with OpenAI.
This is an independent and unofficial project.
Use at your own risk.