Telegram chat bot with OpenAI API using GPT-3 engine based on pyrogram
A simple version of Dewdrop, bcz I lazy to finish that
- Interact to ChatGPT within telegram bot.
- Support custom engine model, see model list.
- Set custom start, help, info text.
- Easy deployable
- Use normal AI chat bot for main and
/ask
command for ChatGPT. - Add jokes, story, weather, and some fun modules.
- Image recognition.
API_ID
&API_HASH
- Get this from my.telegram.orgBOT_TOKEN
- Visit @BotFather and send/newbot
. You will see instructions to create a new bot.API_KEY
- First you need to create OpenAI account, and click this to create new api key.USERNAME
- Your bot username without @.
Bcz I getting confused with Client.get_me(), so you need to put bot username manually, will very thanks if someone want to help me.
- Run locally
VPS
:
- Always update before do anything
apt-get update && apt-get upgrade -y
- Install python and git module
apt-get install python3 git
- Clone this repository
git clone https://github.com/Leoksu/DewChatGPT && cd DewChatGPT
- install all required python package
pip3 install -r requirements.txt
- Copy sample.env to .env
cp sample.env .env
- Fill all variables in .env file with your favorite text editor
- or just use nano,
nano .env
- or just use nano,
- See Here to customize bot text
- Use screen or tmux to keep your bot running in background
screen -S dew
- Finnaly run the bot
python3 dew.py
- Then use
CTRL+A
andCTRL+D
to close screen - If you want to stop the bot or check logs run
screen -r dew
- Default model is
text-ada-001
which is faster and cheaper to avoid token limit. - See model list and more info in OpenAi site.
- Go to dew.py file.
def generate_text(prompt):
data = {
'prompt': prompt,
'model': 'text-ada-001', # edit this value to model you want
'temperature': 0.5,
'max_tokens': 1024, # you can also change max token in one msg
'n': 1,
'stop': None,
'temperature': 0.9,
'top_p': 0.3,
'frequency_penalty': 0.5,
}
- That's it, keep in mind that every engine models have different cost, choose the one that suits your needs.
- Set your own start text, help text, and more
- Simply go to this file and edit it to your desired text