This project is a Telegram Chatbot that uses OpenAI's GPT language model to generate responses to user messages. The bot can be used in both private conversations and group chats.
To use this Chatbot, you'll need the following:
- A Telegram account
- A Telegram bot token (you can get one by talking to the BotFather)
- An OpenAI API key (you can get one by signing up for OpenAI's GPT service)
To install and run the Chatbot, follow these steps:
- Clone this repository to your local machine.
- Install the required dependencies using
go get
go get github.com/go-telegram-bot-api/telegram-bot-api
- Set the following environment variables in
config.yml
:
telegram_api_key: your-Telegram-bot-token
openai_api_key: your-OpenAI-API-key
- Start the Chatbot by running the following command:
go run main.go
Start new chat with the bot by sending a message to it. The bot will respond with a generated message. You can also add the bot to a group chat and it will respond to messages in the group.
For every user or chat ID bot stores some context, size of the context is defined by maxTokens
parameter in a ContextManager
.
Bot recognizes commands in the following format:
ask regular question to the bot, you don`t need to use this command in a private chat, just ask a question
/ask question
set a topic or subject for the bot to talk about, this will be added to the beginning of the generated prompts
/topic some subject
clear the cashed context and topic
/clear
some experimental features to use ChatGPT as a word translator
/cat translate word from Catalan to English
/cas translate word from Spanish to English
bot will respond with a random fact
/hello
bot will respond with a help message, describing the commands
/help
This project is licensed under the MIT License. See the LICENSE
file for details.
This project was inspired by OpenAI's GPT language model and the Telegram Bot API. Thanks to both projects for their great work!