Skip to content

Commit

Permalink
支持gpt-4-gizmo-XXX,填错自动回退gpt-3.5-turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanyutin753 committed Mar 4, 2024
1 parent 36bd290 commit e7f97f4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
31 changes: 26 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '【仅供临时测试使用】 '

# 解析响应中的信息
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e7f97f4

Please sign in to comment.