Delete app.py
Browse files
app.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import requests
|
| 3 |
-
import gradio as gr
|
| 4 |
-
from telegram.ext import ApplicationBuilder, MessageHandler, filters, ContextTypes
|
| 5 |
-
from telegram import Update
|
| 6 |
-
|
| 7 |
-
TOKEN = os.environ.get("TELEGRAM_TOKEN")
|
| 8 |
-
API_KEY = os.environ.get("HERMES_API_KEY")
|
| 9 |
-
URL = "https://api.openrouter.ai/v1/chat/completions"
|
| 10 |
-
|
| 11 |
-
async def reply(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 12 |
-
user_text = update.message.text
|
| 13 |
-
headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
|
| 14 |
-
payload = {
|
| 15 |
-
"model": "nousresearch/hermes-3-llama-3.1-8b",
|
| 16 |
-
"messages": [{"role": "user", "content": user_text}]
|
| 17 |
-
}
|
| 18 |
-
response = requests.post(URL, json=payload, headers=headers).json()
|
| 19 |
-
await update.message.reply_text(response['choices'][0]['message']['content'])
|
| 20 |
-
|
| 21 |
-
def dummy(): return "Bot is running"
|
| 22 |
-
demo = gr.Interface(fn=dummy, inputs=[], outputs="text")
|
| 23 |
-
|
| 24 |
-
if __name__ == "__main__":
|
| 25 |
-
app = ApplicationBuilder().token(TOKEN).build()
|
| 26 |
-
app.add_handler(MessageHandler(filters.TEXT, reply))
|
| 27 |
-
app.run_polling()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|