From 865a7d3dbf43289a23cc6f1796cf74e598948fe4 Mon Sep 17 00:00:00 2001 From: Wizerd Date: Mon, 15 Jan 2024 15:39:09 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E4=BC=98=E5=8C=96=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 1101e13..4cc0013 100644 --- a/main.py +++ b/main.py @@ -197,9 +197,9 @@ CORS(app, resources={r"/images/*": {"origins": "*"}}) PANDORA_UPLOAD_URL = 'files.pandoranext.com' -VERSION = '0.4.10' +VERSION = '0.5.0' # VERSION = 'test' -UPDATE_INFO = '支持自定义Redis配置' +UPDATE_INFO = '优化会话删除机制,使得对话生成过程中也不会出现对话记录' # UPDATE_INFO = '【仅供临时测试使用】 ' with app.app_context(): @@ -735,6 +735,10 @@ def send_text_prompt_and_get_response(messages, api_key, stream, model): payload = generate_gpts_payload(model, formatted_messages) if not payload: raise Exception('model is not accessible') + # 根据NEED_DELETE_CONVERSATION_AFTER_RESPONSE修改history_and_training_disabled + if NEED_DELETE_CONVERSATION_AFTER_RESPONSE: + logger.debug(f"是否保留会话: {NEED_DELETE_CONVERSATION_AFTER_RESPONSE == False}") + payload['history_and_training_disabled'] = True if ori_model_name != 'gpt-3.5-turbo': if CUSTOM_ARKOSE: token = get_token() @@ -1621,9 +1625,9 @@ def chat_completions(): fetcher_thread.join() keep_alive_thread.join() - if conversation_id: - # print(f"准备删除的会话id: {conversation_id}") - delete_conversation(conversation_id, api_key) + # if conversation_id: + # # print(f"准备删除的会话id: {conversation_id}") + # delete_conversation(conversation_id, api_key) if not stream: @@ -2005,7 +2009,7 @@ def images_generations(): yield 'data: ' + json.dumps(new_data) + '\n\n' if buffer: # print(f"最后的数据: {buffer}") - delete_conversation(conversation_id, api_key) + # delete_conversation(conversation_id, api_key) try: buffer_json = json.loads(buffer) error_message = buffer_json.get("detail", {}).get("message", "未知错误") @@ -2034,7 +2038,7 @@ def images_generations(): logger.info(f"发送最后的数据: {buffer}") yield buffer - delete_conversation(conversation_id, api_key) + # delete_conversation(conversation_id, api_key) # 执行流式响应的生成函数来累积 all_new_text # 迭代生成器对象以执行其内部逻辑