File size: 728 Bytes
e22ba9d
a4afdf9
e22ba9d
 
a4afdf9
 
e22ba9d
a4afdf9
e22ba9d
a4afdf9
 
 
e22ba9d
 
 
a4afdf9
 
e22ba9d
a4afdf9
e22ba9d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()