Emkay commited on
Commit
42b0389
·
1 Parent(s): 51cf5fc

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -34
app.py DELETED
@@ -1,34 +0,0 @@
1
- from telegram import Update
2
- from telegram.ext import Updater, CommandHandler, CallbackContext, MessageHandler, Filters
3
- import requests
4
- from telegram import ChatAction
5
- import os
6
-
7
- def hello(update: Update, context: CallbackContext) -> None:
8
- intro_text = """
9
- 🤖 Greetings human! \n
10
- 🤗 I'm a bot hosted on Hugging Face Spaces. \n
11
- 🦾 I can query the mighty GPT-J-6B model and send you a response here. Try me.\n
12
- ✉️ Send me a text to start and I shall generate a response to complete your text!\n\n
13
- ‼️ PS: Responses are not my own (everything's from GPT-J-6B). I'm not conscious (yet).\n
14
- """
15
- update.message.reply_text(intro_text)
16
-
17
- def get_gpt_response(text):
18
- r = requests.post(
19
- url="https://hf.space/Emkay/Asrix_Bot/gpt-j-6B/+/api/predict/",
20
- json={"data": [text]},
21
- )
22
- response = r.json()
23
- return response["data"][0]
24
-
25
- def respond_to_user(update: Update, context: CallbackContext):
26
- update.message.chat.send_action(action=ChatAction.TYPING)
27
- response_text = get_gpt_response(update.message.text)
28
- update.message.reply_text(response_text)
29
-
30
- updater = Updater(os.environ['telegram_token'])
31
- updater.dispatcher.add_handler(CommandHandler("start", hello))
32
- updater.dispatcher.add_handler(MessageHandler(Filters.text & ~Filters.command, respond_to_user))
33
- updater.start_polling()
34
- updater.idle()