This GitHub repository contains the implementation of a telegram bot, designed to facilitate seamless interaction with GPT-3.5 and GPT-4, state-of-the-art language models by OpenAI.
GPT-4o support (with vision)
Custom OpenAI API compatible endpoints support (see app/llm_models.py for example of using WizardLM-2 8x22b via OpenRouter.ai)
DALL-E 3 Image generation support
? Key Features
app/llm_models.py
app/context/function_manager.py file for more details.app/context/context_manager.py file. When context size exceeds this limit, bot will automatically summarize context.? Installation
To get this bot up and running, follow these steps:
TELEGRAM_BOT_TOKEN and OPENAI_TOKEN variables in the settings.py file.IMAGE_PROXY_URL to your server IP / hostname in the settings.py file.USER_ROLE_MANAGER_CHAT_ID variable in the settings.py file to your telegram id. This is required for access control.ENABLE_USER_ROLE_MANAGER_CHAT variable in the settings.py file to True. This is required for access control.USER_ROLE_* variables in the settings.py file to desired roles.docker-compose up -d in the root directory of the project.If you've done optional steps, when you send your first message to the bot, you will get a management message with your telegram id and info. You can use this message to setup your role as admin.
? Commands
/reset - reset current dialog
/usage - show usage for current month
/models - open models menu
/settings - open settings menu
/text2speech - generate voice message from message (last message or replied)
/usage_all - show usage for all users
These commands will provide additional interaction control for the bot users. You can find most settings in settings menu, commands are just shortcuts for them.
If you have any issues with the bot, please create an issue in this repository. I will try to help you as soon as possible.
Here are some typical issues and solutions:
Error code: 400 - {'error': {'message': 'Invalid image.', 'type': 'invalid_request_error' ...}} - This error usually occurs when openai cannot access the image. Make sure you set up the IMAGE_PROXY_URL variable correctly with your server IP / hostname.
You can try to open this url in your browser to check if it works. Also you can debug the setup by looking at chatgpttg.message table in postgres, there will be message with image url. You can try to open this url in your browser to check if it works.Error code: 400 - {'error': {'message': 'Invalid content type. image_url is only supported by certain models.', 'type': 'invalid_request_error' ...}} - This error usually occurs when you have image in your context, but current model doesn't support vision. You can try to change model to gpt-4-vision-preview or reset your context with /reset command.