Modir19 commited on
Commit
7c7451c
·
verified ·
1 Parent(s): cbdc090

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

Files changed (1) hide show
  1. requirements.txt. +3 -0
requirements.txt. ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+
2
+ python-telegram-bot
3
+ groq