Spaces:
Configuration error
app.py.
import os
import asyncio
from groq import Groq
from telegram import Update
from telegram.ext import Application, MessageHandler, filters, ContextTypes
CONFIG
GROQ_KEY = "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"
TELEGRAM_TOKEN = "8239686025:AAEp_kfqMd_CMB0SN0SAHPGYyJ5-pXYVuZQ"
client = Groq(api_key=GROQ_KEY)
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
try:
completion = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": update.message.text}]
)
await update.message.reply_text(completion.choices[0].message.content)
except Exception as e:
print(f"Error: {e}")
async def main():
application = Application.builder().token(TELEGRAM_TOKEN).build()
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message))
async with application:
await application.initialize()
await application.start_polling()
# Keep running forever
await asyncio.Event().wait()
if name == 'main':
try:
asyncio.run(main())
except KeyboardInterrupt:
pass