typesdigital's picture
Update app.py
0d58968
raw
history blame contribute delete
648 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.Completion.create(
engine="davinci",
prompt="Hello, world!",
max_tokens=5
)
update.message.reply_text(response.choices[0].text)
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()