Modir19 commited on
Commit
cbdc090
·
verified ·
1 Parent(s): 9a463b8

Commit new file to main ✅

Browse files

import os
import asyncio
from groq import Groq
from telegram import Update
from telegram.ext import Application, MessageHandler, filters, ContextTypes

# CONFIGURATION
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()
await asyncio.Event().wait()

if __name__ == '__main__':
try:
asyncio.run(main())
except KeyboardInterrupt:
pass

Files changed (1) hide show
  1. /"Files and +2 -0
/"Files and ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ python-telegram-bot
2
+ groq