enotkrutoy commited on
Commit
03bb072
·
verified ·
1 Parent(s): 2b8f2c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,9 +1,30 @@
 
1
  from telegram import Update
2
-
3
  from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, filters, ContextTypes
4
  import requests
5
  import json
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  HF_API_KEY = os.getenv("HF_API_KEY")
9
  HF_API_URL = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions"
 
1
+ import os
2
  from telegram import Update
 
3
  from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, filters, ContextTypes
4
  import requests
5
  import json
6
 
7
+ HF_API_KEY = os.getenv("HF_API_KEY")
8
+ HF_API_URL = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions"
9
+
10
+ # Обработчик стартовой команды
11
+ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
12
+ await update.message.reply_text("Привет! Я бот, который отвечает на ваши вопросы. Напишите мне что-нибудь.")
13
+
14
+ # Обработчик сообщений
15
+ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
16
+ user_message = update.message.text
17
+ await update.message.reply_text("Думаю...")
18
+
19
+ # Формируем запрос к API Hugging Face
20
+ headers = {
21
+ "Authorization": f"Bearer {HF_API_KEY}",
22
+ "Content-Type": "application/json",
23
+ }
24
+
25
+ payl
26
+
27
+
28
 
29
  HF_API_KEY = os.getenv("HF_API_KEY")
30
  HF_API_URL = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions"