Telegram chatbot that uses OpenAI's GPT API to generate responses Chatbot also translates voice messages to text and uses them as input when user says
- /new, start a new conversation
- /role, set the role of the user
- /stats, show usage statistics
- /suggestions , show suggestions in keyboard
- /help writes the help message
VOICE_MODEL = "whisper-1" TEXT_MODEL = "gpt-3.5-turbo"
To use this script, you will need to have Python 3.7 or later installed. You can download Python from the official website.
You will also need to install the following Python packages:
openai
aiogram
pydub
also you will need to install ffmpeg to convert voice messages to format that Whisper can transcribe to text
- Clone this repository to your local machine.
- Create an account on the OpenAI website and obtain an API key.
- Create a api_key.py file in the same directory as the script, and add your OpenAI API key to it.
key = "YOUR_API_KEY"
- Create a new bot on Telegram and obtain the bot_token.
- Run the script using the following command:
python openaitelegram.py
- Start a conversation with the bot on Telegram
- use /new command to start a new conversation.
- Add basic statistics
- Add suggestions keyboard
- Add incoming voice messages support
- Add feedback pool
- Add outgoing voice messages support
- Add web-site summary and Q&A
- Add document Q&A using langchain
You need to run this script on a server so that it can run 24/7, otherwise it will run only when you run the script on your local machine. Works on my Raspberry Pi 2 Model B
This script is licensed under the MIT license. Feel free to use and modify it for your own projects
Feel free to contribute to this project by creating a pull request. Any contributions are welcome and appreciated.