File size: 570 Bytes
be0bcf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()