Download app.py from saang5550/MyBot: direct link, hf CLI and curl.
- Browser
- Download file 728 Bytes
-
https://huggingface.co/spaces/saang5550/MyBot/resolve/main/app.py
- Command line
-
hf download hf://spaces/saang5550/MyBot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/saang5550/MyBot/resolve/main/app.py
728 Bytes
| from telegram import Update | |
| from telegram.ext import ApplicationBuilder, MessageHandler, CommandHandler, filters | |
| from transformers import pipeline | |
| # Load free Hugging Face model | |
| chat = pipeline("text-generation", model="TheBloke/guanaco-7B-HF") | |
| BOT_TOKEN = "8209585796:AAEWyibM5fll6YKXPp3V5ld2zuLOPP0RbEk" | |
| # Text chat | |
| async def chat_text(update: Update, context): | |
| user_text = update.message.text | |
| ai_response = chat(user_text, max_length=200)[0]['generated_text'] | |
| await update.message.reply_text(ai_response) | |
| # You can later add /image, /voice, /search commands here | |
| app = ApplicationBuilder().token(BOT_TOKEN).build() | |
| app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, chat_text)) | |
| app.run_polling() |