|
|
@ -29,6 +29,23 @@ def send_welcome(message):
|
|
|
|
from api import *
|
|
|
|
from api import *
|
|
|
|
|
|
|
|
|
|
|
|
setted_models = {}
|
|
|
|
setted_models = {}
|
|
|
|
|
|
|
|
system_prompts = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['info'])
|
|
|
|
|
|
|
|
def info(message):
|
|
|
|
|
|
|
|
global setted_models, system_prompts
|
|
|
|
|
|
|
|
id = str(message.chat.id)
|
|
|
|
|
|
|
|
if id not in setted_models:
|
|
|
|
|
|
|
|
setted_models[id] = "0.1"
|
|
|
|
|
|
|
|
if id not in system_prompts:
|
|
|
|
|
|
|
|
prompt = "None"
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
prompt = system_prompts[str(message.chat.id)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bot.send_message(message.chat.id, f"""____ Информация ____
|
|
|
|
|
|
|
|
Версия: {setted_models[id]}
|
|
|
|
|
|
|
|
System-prompt: {telebot.formatting.hcode(prompt)}
|
|
|
|
|
|
|
|
""", parse_mode="HTML")
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['model'])
|
|
|
|
@bot.message_handler(commands=['model'])
|
|
|
|
def set_model(message):
|
|
|
|
def set_model(message):
|
|
|
@ -46,16 +63,35 @@ def set_model(message):
|
|
|
|
bot.reply_to(message, "Неизвестная модель")
|
|
|
|
bot.reply_to(message, "Неизвестная модель")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['prompt'])
|
|
|
|
|
|
|
|
def set_prompt(message):
|
|
|
|
|
|
|
|
global system_prompts
|
|
|
|
|
|
|
|
system_prompts[str(message.chat.id)] = message.text[8:]
|
|
|
|
|
|
|
|
bot.reply_to(message, "Установлен новый system-prompt")
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['cprompt'])
|
|
|
|
|
|
|
|
def clear_prompt(message):
|
|
|
|
|
|
|
|
global system_prompts
|
|
|
|
|
|
|
|
system_prompts.pop(str(message.chat.id))
|
|
|
|
|
|
|
|
bot.reply_to(message, "System-prompt очищен")
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(func=lambda message: True)
|
|
|
|
@bot.message_handler(func=lambda message: True)
|
|
|
|
def echo_message(message):
|
|
|
|
def echo_message(message):
|
|
|
|
global setted_models
|
|
|
|
global setted_models, system_prompts
|
|
|
|
prompt = 'Отвечай кратко не давая никакой лишней информации и не делая своих умозаключений. \n\n' + message.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id = str(message.chat.id)
|
|
|
|
id = str(message.chat.id)
|
|
|
|
if id not in setted_models:
|
|
|
|
if id not in setted_models:
|
|
|
|
setted_models[id] = "0.1"
|
|
|
|
setted_models[id] = "0.1"
|
|
|
|
bot.reply_to(message, gen(prompt, message.chat.id, setted_models[id]))
|
|
|
|
|
|
|
|
|
|
|
|
if id in system_prompts:
|
|
|
|
|
|
|
|
prompt = '[INST]' + system_prompts[id] + '[/INST]\n\n' + message.text
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
prompt = message.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
st = bot.send_message(message.chat.id, "Печатает...")
|
|
|
|
|
|
|
|
bot.reply_to(message, gen(prompt, message.chat.id, setted_models[id]).replace(r'\n', '\n'), parse_mode="HTML")
|
|
|
|
|
|
|
|
bot.delete_message(message.chat.id, st.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############
|
|
|
|
############
|
|
|
|
|
|
|
|
|
|
|
|