MVP status. Adding: auto cleaning DB, welcome message in private(PM)chat, forum type chat support, some optimization

This commit is contained in:
armatik 2023-07-13 11:08:15 +03:00
parent 96b257fb6b
commit 2e804f15f4

View File

@ -9,6 +9,7 @@ config.read(os.path.join(mother_path, 'src/config.ini'))
database = sqlite3.connect(os.path.join(mother_path, 'DataBase/OCAB_DB.db'))
cursor = database.cursor()
reply_ignore = config['Telegram']['reply_ignore'].split('| ')
# Импорт библиотек
@ -79,40 +80,6 @@ def openai_collecting_message(message_id, message_formated_text):
return message_formated_text
# if (((cursor.execute("SELECT answer_id FROM message_list WHERE message_id") is None)) or (cursor.execute("SELECT answer_id FROM message_list WHERE message_id") == 643885)):
# openai_collecting_message(cursor.execute("SELECT answer_id FROM message_list WHERE message_id"))
# # проверяем что с новым сообщение длина всех сообщений в цепочке не будет превышать max_token_count
# count_length = 0
# for message in message_formated_text:
# count_length += len(message['content'])
# if count_length + len(cursor.execute("SELECT message_text FROM message_list WHERE message_id = ?", (message_id,)).fetchone()) > max_token_count:
# message_formated_text.pop(1)
# print(int(*(cursor.execute("SELECT message_sender FROM message_list WHERE message_id = ?", (message_id,)).fetchone())))
# if int(*(cursor.execute("SELECT message_sender FROM message_list WHERE message_id = ?", (message_id,)).fetchone())) == 0:
# message_formated_text.append({
# "role": "assistant",
# "content": str(*(cursor.execute("SELECT message_text FROM message_list WHERE message_id = ?", (message_id,)).fetchone()))
# })
# else:
# message_formated_text.append({
# "role": "user",
# "content": str(*(cursor.execute("SELECT message_text FROM message_list WHERE message_id = ?", (message_id,)).fetchone()))
# })
def openai_message_processing(message_id):
#проверяем на наличие сообщения в базе данных
if cursor.execute("SELECT message_text FROM message_list WHERE message_id = ?", (message_id,)).fetchone() is None: