chatgpt_telegram_bot
This repository contains the code for a Telegram bot that leverages OpenAI's GPT-3 API to generate natural language responses. The bot is written in Python and uses the Flask web framework to handle incoming requests from Telegram's bot API. The result is a fast and reliable experience, with response times usually taking only 3-5 seconds.
Key Features
- Rapid response times
- No limitations on the number of requests
- Syntax highlighting for code snippets
- Custom chat modes, including Personal Assistant and Code Assistant
- Whitelist of authorized Telegram users
- Monitoring of API usage costs using the OpenAI API
Bot Commands
/retry - Regenerates the previous bot response /new - Initiates a new conversation /mode - Selects the chat mode /balance - Displays current usage costs /help - Displays a help prompt
Deployment
- Obtain an OpenAI API key
- Acquire a Telegram bot token from @BotFather
- Customize config/config.example.yml with your tokens, then run the following commands (experienced users may also edit config/config.example.env): " mv config/config.example.yml config/config.yml mv config/config.example.env config/config.env "
- Finally, lauch the deployment " docker-compose --env-file config/config.env up --build "
Docker
- In order to run the project in a Docker container, you will need to add the following steps to the deployment process:
Install Docker on your machine
- Run the following commands in the project root directory: " RUN python -m pip install --upgrade pip RUN pip3 install -r requirements.txt --root-user-action=ignore ENV PIP_ROOT_USER_ACTION=ignore "