my_test_bot / bot.py
Makaria's picture
Обновление кода с новым токеном
be0bcf5
raw
history blame
570 Bytes
import os
import telebot
from huggingface_hub import InferenceClient
# Получаем токены из окружения
hf_token = os.getenv("HUGGINGFACE_TOKEN")
tg_token = os.getenv("TG_TOKEN")
bot = telebot.TeleBot(tg_token)
client = InferenceClient("sambanovasystems/SambaLingo-Russian-Chat", token=hf_token)
@bot.message_handler(func=lambda message: True)
def echo_all(message):
response = client.chat_completion(messages=[{"role": "user", "content": message.text}])
bot.reply_to(message, response['choices'][0]['message']['content'])
bot.polling()