typesdigital's picture
Create app.py
1ec7fd7
raw
history blame
731 Bytes
from telegram.ext import Updater, MessageHandler, Filters
import openai
openai.api_key = "<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>"
TELEGRAM_API_TOKEN = "<6074730982:AAGKU2_gpogdkTQvmE4Ya63n9ot2dHVzA7I>"
def text_message(update, context):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages= [{"role": "system", "content": "Ass a silly phrase after each one of your answers"}]
)
update.message.reply_text(response["choices"][0]["message"]["content"])
updater = Updater(TELEGRAM_API_TOKEN, use_context=True)
dispatcher = updater.dispatcher
dispatcher.add_handler(MessageHandler(Filters.text & (~Filters.command), text_message))
updater.start_polling()
updater.idle()