过滤对话的html代码

This commit is contained in:
w_xiaolizu
2023-05-22 10:35:28 +08:00
parent bf6f5c433d
commit 9f871deb4d
2 changed files with 5 additions and 3 deletions

View File

@ -364,10 +364,12 @@ def show_prompt_result(index, data: gr.Dataset, chatbot):
def thread_write_chat(chatbot): def thread_write_chat(chatbot):
private_key = toolbox.get_conf('private_key')[0] private_key = toolbox.get_conf('private_key')[0]
chat_title = chatbot[0][0].split() chat_title = chatbot[0][0].split()
i_say = chatbot[-1][0].strip("<p>/p")
gpt_result = chatbot[-1][1].strip('<div class="markdown-body">/div')
if private_key in chat_title: if private_key in chat_title:
SqliteHandle(f'ai_private_{chat_title[-2]}').inset_prompt({chatbot[-1][0]: chatbot[-1][1]}) SqliteHandle(f'ai_private_{chat_title[-2]}').inset_prompt({i_say: gpt_result})
else: else:
SqliteHandle(f'ai_common').inset_prompt({chatbot[-1][0]: chatbot[-1][1]}) SqliteHandle(f'ai_common').inset_prompt({i_say: gpt_result})
base_path = os.path.dirname(__file__) base_path = os.path.dirname(__file__)

View File

@ -41,7 +41,7 @@ class SqliteHandle:
self.__connect.close() self.__connect.close()
def create_tab(self): def create_tab(self):
self.__cursor.execute(f"CREATE TABLE `{self.__table}` ('id' INTEGER PRIMARY KEY AUTOINCREMENT, 'prompt' TEXT, 'result' TEXT)") self.__cursor.execute(f"CREATE TABLE `{self.__table}` ( 'prompt' TEXT, 'result' TEXT)")
def get_tables(self): def get_tables(self):
all_tab = [] all_tab = []