From e7f97f4104a2f87d47d2e3a87d199512f39393e1 Mon Sep 17 00:00:00 2001 From: Yanyutin753 <3254822118@qq.com> Date: Mon, 4 Mar 2024 15:08:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81gpt-4-gizmo-XXX=EF=BC=8C?= =?UTF-8?q?=E5=A1=AB=E9=94=99=E8=87=AA=E5=8A=A8=E5=9B=9E=E9=80=80gpt-3.5-t?= =?UTF-8?q?urbo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 31 ++++++++++++++++++++++++++----- start.sh | 2 +- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 70d54d8..4328f0e 100644 --- a/main.py +++ b/main.py @@ -321,9 +321,9 @@ def generate_gpts_payload(model, messages): # PANDORA_UPLOAD_URL = 'files.pandoranext.com' -VERSION = '0.7.7.1' +VERSION = '0.7.7.2' # VERSION = 'test' -UPDATE_INFO = '支持gpt-4-gizmo-XXX,动态配置GPTS' +UPDATE_INFO = '支持gpt-4-gizmo-XXX,填错自动回退gpt-3.5-turbo' # UPDATE_INFO = '【仅供临时测试使用】 ' # 解析响应中的信息 @@ -944,7 +944,28 @@ def send_text_prompt_and_get_response(messages, api_key, stream, model): logger.info(f"Model already exists in the list, skipping...") payload = generate_gpts_payload(model, formatted_messages) else: - raise Exception('KEY_FOR_GPTS_INFO is not accessible') + payload = { + # 构建 payload + "action": "next", + "messages": formatted_messages, + "parent_message_id": str(uuid.uuid4()), + "model": "text-davinci-002-render-sha", + "timezone_offset_min": -480, + "suggestions": [ + "What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter.", + "I want to cheer up my friend who's having a rough day. Can you suggest a couple short and sweet text messages to go with a kitten gif?", + "Come up with 5 concepts for a retro-style arcade game.", + "I have a photoshoot tomorrow. Can you recommend me some colors and outfit options that will look good on camera?" + ], + "history_and_training_disabled": False, + "arkose_token": None, + "conversation_mode": { + "kind": "primary_assistant" + }, + "force_paragen": False, + "force_rate_limit": False + } + logger.debug('KEY_FOR_GPTS_INFO is not accessible') else: payload = generate_gpts_payload(model, formatted_messages) if not payload: @@ -1188,7 +1209,7 @@ def generate_actions_allow_payload(author_role, author_name, target_message_id, "action": "next", "messages": [ { - "id": generate_custom_uuid_v4(), + "id": str(uuid.uuid4()), "author": { "role": author_role, "name": author_name @@ -2039,7 +2060,7 @@ def old_data_fetcher(upstream_response, data_queue, stop_event, last_data_time, "id": chat_message_id, "object": "chat.completion.chunk", "created": timestamp, - "model": message.get("metadata", {}).get("model_slug"), + "model": model, "choices": [ { "index": 0, diff --git a/start.sh b/start.sh index e2af8d9..f27e778 100755 --- a/start.sh +++ b/start.sh @@ -31,4 +31,4 @@ echo "PROCESS_WORKERS: ${PROCESS_WORKERS}" echo "PROCESS_THREADS: ${PROCESS_THREADS}" # 启动 Gunicorn 并使用 tee 命令同时输出日志到文件和控制台 -exec gunicorn -w ${PROCESS_WORKERS} --threads ${PROCESS_THREADS} --bind 0.0.0.0:33333 main:app --access-logfile - --error-logfile - +exec gunicorn -w ${PROCESS_WORKERS} --threads ${PROCESS_THREADS} --bind 0.0.0.0:33333 main:app --access-logfile - --error-logfile - --timeout 60