Add help, add clear context and short commands.

main
t 10 months ago
parent ff82eb49dd
commit ea121d6e28

@ -21,8 +21,23 @@ bot = telebot.TeleBot(API_TOKEN)
@bot.message_handler(commands=['help', 'start']) @bot.message_handler(commands=['help', 'start'])
def send_welcome(message): 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 ### ### MAIN ###
@ -30,8 +45,9 @@ from api import *
setted_models = {} setted_models = {}
system_prompts = {} system_prompts = {}
onoff = {}
@bot.message_handler(commands=['info']) @bot.message_handler(commands=['info','i'])
def info(message): def info(message):
global setted_models, system_prompts global setted_models, system_prompts
id = str(message.chat.id) id = str(message.chat.id)
@ -47,7 +63,7 @@ def info(message):
System-prompt: {telebot.formatting.hcode(prompt)} System-prompt: {telebot.formatting.hcode(prompt)}
""", parse_mode="HTML") """, parse_mode="HTML")
@bot.message_handler(commands=['model']) @bot.message_handler(commands=['model','m'])
def set_model(message): def set_model(message):
global setted_models, iddb global setted_models, iddb
try: try:
@ -63,16 +79,34 @@ def set_model(message):
bot.reply_to(message, "Неизвестная модель") bot.reply_to(message, "Неизвестная модель")
@bot.message_handler(commands=['prompt']) @bot.message_handler(commands=['prompt','p'])
def set_prompt(message): def set_prompt(message):
global system_prompts global system_prompts
system_prompts[str(message.chat.id)] = message.text[8:] system_prompts[str(message.chat.id)] = message.text[8:]
bot.reply_to(message, "Установлен новый system-prompt") bot.reply_to(message, "Установлен новый system-prompt 🤖")
@bot.message_handler(commands=['cprompt']) @bot.message_handler(commands=['cprompt','cp'])
def clear_prompt(message): def clear_prompt(message):
global system_prompts global system_prompts
system_prompts.pop(str(message.chat.id)) try:
bot.reply_to(message, "System-prompt очищен") system_prompts.pop(str(message.chat.id))
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) @bot.message_handler(func=lambda message: True)
def echo_message(message): def echo_message(message):
@ -88,9 +122,14 @@ def echo_message(message):
prompt = message.text prompt = message.text
st = bot.send_message(message.chat.id, "Печатает...") 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") predicted = gen(prompt, message.chat.id, setted_models[id])
bot.delete_message(message.chat.id, st.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)
############ ############

Loading…
Cancel
Save