MyBot / app.py
saang5550's picture
Update app.py
a4afdf9 verified
Raw History Blame Contribute Delete
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()