|
|
|
@ -21,8 +21,23 @@ bot = telebot.TeleBot(API_TOKEN)
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['help', 'start'])
|
|
|
|
|
def send_welcome(message):
|
|
|
|
|
bot.reply_to(message, "Скоро...")
|
|
|
|
|
bot.reply_to(message, f"""Это подобие ChatGPT на минималках.
|
|
|
|
|
|
|
|
|
|
__ Есть 2 версии:
|
|
|
|
|
{telebot.formatting.hcode("/m 0.1")} - Простейшая, быстрая, краткая, не помнит что вы говорили.
|
|
|
|
|
{telebot.formatting.hcode("/m 0.2")} - Умнее, относительно быстрая, помнит что вы говорили.
|
|
|
|
|
|
|
|
|
|
__ Список кратких команд:
|
|
|
|
|
/info - /i
|
|
|
|
|
/model - /m
|
|
|
|
|
/ccontext - /cc
|
|
|
|
|
/prompt - /p
|
|
|
|
|
/cprompt - /cp
|
|
|
|
|
|
|
|
|
|
Канал разработчика: @justuser31
|
|
|
|
|
Ещё проекты: @just_openbots (тут много интересного)
|
|
|
|
|
{telebot.formatting.hlink("Исходный код","https://gitea.gulyaipole.fun/justuser/just_minigpt")}
|
|
|
|
|
""", parse_mode = "HTML")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### MAIN ###
|
|
|
|
@ -30,8 +45,9 @@ from api import *
|
|
|
|
|
|
|
|
|
|
setted_models = {}
|
|
|
|
|
system_prompts = {}
|
|
|
|
|
onoff = {}
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['info'])
|
|
|
|
|
@bot.message_handler(commands=['info','i'])
|
|
|
|
|
def info(message):
|
|
|
|
|
global setted_models, system_prompts
|
|
|
|
|
id = str(message.chat.id)
|
|
|
|
@ -47,7 +63,7 @@ def info(message):
|
|
|
|
|
System-prompt: {telebot.formatting.hcode(prompt)}
|
|
|
|
|
""", parse_mode="HTML")
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['model'])
|
|
|
|
|
@bot.message_handler(commands=['model','m'])
|
|
|
|
|
def set_model(message):
|
|
|
|
|
global setted_models, iddb
|
|
|
|
|
try:
|
|
|
|
@ -63,16 +79,34 @@ def set_model(message):
|
|
|
|
|
bot.reply_to(message, "Неизвестная модель")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['prompt'])
|
|
|
|
|
@bot.message_handler(commands=['prompt','p'])
|
|
|
|
|
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'])
|
|
|
|
|
bot.reply_to(message, "Установлен новый system-prompt 🤖")
|
|
|
|
|
@bot.message_handler(commands=['cprompt','cp'])
|
|
|
|
|
def clear_prompt(message):
|
|
|
|
|
global system_prompts
|
|
|
|
|
try:
|
|
|
|
|
system_prompts.pop(str(message.chat.id))
|
|
|
|
|
bot.reply_to(message, "System-prompt очищен")
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
bot.reply_to(message, "System-prompt очищен 🤖")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['ccontext','cc'])
|
|
|
|
|
def clear_context(message):
|
|
|
|
|
global iddb
|
|
|
|
|
try:
|
|
|
|
|
iddb.pop(str(message.chat.id))
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
bot.reply_to(message, "Контекст очищен 🤖")
|
|
|
|
|
|
|
|
|
|
#@bot.message_handler(commands=['onoff'])
|
|
|
|
|
#def set_onoff(message):
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(func=lambda message: True)
|
|
|
|
|
def echo_message(message):
|
|
|
|
@ -88,9 +122,14 @@ def echo_message(message):
|
|
|
|
|
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)
|
|
|
|
|
predicted = gen(prompt, message.chat.id, setted_models[id])
|
|
|
|
|
fixed = predicted.replace(r'\n', '\n').replace('\\ n', '\n')
|
|
|
|
|
try:
|
|
|
|
|
bot.reply_to(message, fixed, parse_mode="Markdown")
|
|
|
|
|
except:
|
|
|
|
|
bot.reply_to(message, fixed, parse_mode="HTML")
|
|
|
|
|
|
|
|
|
|
bot.delete_message(message.chat.id, st.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############
|
|
|
|
|