BotAi / app.py
saang5550's picture
requirements.txt
f3cefa2 verified
Raw History Blame Contribute Delete
687 Bytes
from telegram import Update
from telegram.ext import ApplicationBuilder, MessageHandler, filters
from transformers import pipeline
# Load a free Hugging Face model
chat = pipeline("text-generation", model="TheBloke/guanaco-7B-HF") # Free chat model
async def reply(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)
# Telegram bot setup
BOT_TOKEN = "8209585796:AAEWyibM5fll6YKXPp3V5ld2zuLOPP0RbEk" # Replace with your bot token
app = ApplicationBuilder().token(BOT_TOKEN).build()
app.add_handler(MessageHandler(filters.TEXT, reply))
app.run_polling()