dedekind-telegram-chat / telegram.py
Sathishkumartheta's picture
Upload 9 files
3ebfa24 verified
raw
history blame contribute delete
708 Bytes
import telebot
import os
import llama_huggingface
import prompts
from dotenv import load_dotenv
load_dotenv()
TELEGRAM_BOT_TOKEN=os.getenv('TELEGRAM_BOT_TOKEN')
bot = telebot.TeleBot(TELEGRAM_BOT_TOKEN)
chat_model=''
def init_telegram(model,repo_id):
global chat_model
if model=='LLAMA':
chat_model=llama_huggingface.init_llama_chatmodel(repo_id=repo_id)
def get_telegram_bot():
global bot
return bot
@bot.message_handler(func=lambda msg: True)
def send_welcome(message):
prompt=prompts.compose_prompt(
system_message='You are an AI',
human_message=message.text
)
reply=chat_model.invoke(prompt)
bot.reply_to(message,reply.content)