mirror of
https://github.com/Yanyutin753/RefreshToV1Api.git
synced 2025-12-23 01:03:16 +08:00
[feat] 增加对 GPT-4-Mobile 模型的支持
This commit is contained in:
12
Readme.md
12
Readme.md
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
### 0.0.8
|
||||||
|
|
||||||
|
- 增加了对 GPT-4-Mobile 模型的支持,模型名为 `gpt-4-mobile`
|
||||||
|
|
||||||
### 0.0.7
|
### 0.0.7
|
||||||
|
|
||||||
- 一定程度上修复图片无法正常生成的问题
|
- 一定程度上修复图片无法正常生成的问题
|
||||||
@@ -51,7 +55,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- OPENAI_API_KEY=<Pandora-Next 的 fk>
|
- OPENAI_API_KEY=<Pandora-Next 的 fk>
|
||||||
- BASE_URL=<backend-to-api容器地址>
|
- BASE_URL=<backend-to-api容器地址>
|
||||||
- CUSTOM_MODELS=+gpt-4-s,+gpt-4-classic
|
- CUSTOM_MODELS=+gpt-4-s,+gpt-4-classic,+gpt-4-mobile
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -67,4 +71,8 @@ services:
|
|||||||
|
|
||||||
### 绘图
|
### 绘图
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
### GPT-4-Mobile
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
@@ -2,7 +2,7 @@ version: '3'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
backend-to-api:
|
backend-to-api:
|
||||||
image: wizerd/pandora-to-api:0.0.7
|
image: wizerd/pandora-to-api:0.0.8
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "50011:33333"
|
- "50011:33333"
|
||||||
@@ -16,7 +16,7 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
uploader:
|
uploader:
|
||||||
image: wizerd/pandora-to-api:0.0.7
|
image: wizerd/pandora-to-api:0.0.8
|
||||||
restart: always
|
restart: always
|
||||||
entrypoint: ["python3", "/app/upload.py"]
|
entrypoint: ["python3", "/app/upload.py"]
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
26
main.py
26
main.py
@@ -26,7 +26,16 @@ BASE_URL = os.getenv('BASE_URL', '')
|
|||||||
PROXY_API_PREFIX = os.getenv('PROXY_API_PREFIX', '')
|
PROXY_API_PREFIX = os.getenv('PROXY_API_PREFIX', '')
|
||||||
UPLOAD_BASE_URL = os.getenv('UPLOAD_BASE_URL', '')
|
UPLOAD_BASE_URL = os.getenv('UPLOAD_BASE_URL', '')
|
||||||
|
|
||||||
|
VERSION = '0.0.8'
|
||||||
|
UPDATE_INFO = '增加了对 GPT-4 Mobile 的支持'
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
# 输出版本信息
|
||||||
|
print(f"==========================================")
|
||||||
|
print(f"Version: {VERSION}")
|
||||||
|
print(f"Update Info: {UPDATE_INFO}")
|
||||||
|
|
||||||
|
|
||||||
if not BASE_URL:
|
if not BASE_URL:
|
||||||
raise Exception('BASE_URL is not set')
|
raise Exception('BASE_URL is not set')
|
||||||
else:
|
else:
|
||||||
@@ -36,6 +45,9 @@ with app.app_context():
|
|||||||
else:
|
else:
|
||||||
print(f"PROXY_API_PREFIX: {PROXY_API_PREFIX}")
|
print(f"PROXY_API_PREFIX: {PROXY_API_PREFIX}")
|
||||||
|
|
||||||
|
print(f"==========================================")
|
||||||
|
|
||||||
|
|
||||||
# 定义获取 token 的函数
|
# 定义获取 token 的函数
|
||||||
def get_token():
|
def get_token():
|
||||||
url = f"{BASE_URL}/{PROXY_API_PREFIX}/api/arkose/token"
|
url = f"{BASE_URL}/{PROXY_API_PREFIX}/api/arkose/token"
|
||||||
@@ -47,6 +59,7 @@ def get_token():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
accessable_model_list = ['gpt-4-classic', 'gpt-4-s', 'gpt-4-mobile']
|
||||||
|
|
||||||
# 定义发送请求的函数
|
# 定义发送请求的函数
|
||||||
def send_text_prompt_and_get_response(messages, api_key, stream, model):
|
def send_text_prompt_and_get_response(messages, api_key, stream, model):
|
||||||
@@ -177,6 +190,18 @@ def send_text_prompt_and_get_response(messages, api_key, stream, model):
|
|||||||
"history_and_training_disabled": False,
|
"history_and_training_disabled": False,
|
||||||
"conversation_mode":{"kind":"primary_assistant"},"force_paragen":False,"force_rate_limit":False
|
"conversation_mode":{"kind":"primary_assistant"},"force_paragen":False,"force_rate_limit":False
|
||||||
}
|
}
|
||||||
|
elif model == 'gpt-4-mobile':
|
||||||
|
payload = {
|
||||||
|
# 构建 payload
|
||||||
|
"action": "next",
|
||||||
|
"messages": formatted_messages,
|
||||||
|
"parent_message_id": str(uuid.uuid4()),
|
||||||
|
"model":"gpt-4-mobile",
|
||||||
|
"timezone_offset_min": -480,
|
||||||
|
"suggestions":["Give me 3 ideas about how to plan good New Years resolutions. Give me some that are personal, family, and professionally-oriented.","Write a text asking a friend to be my plus-one at a wedding next month. I want to keep it super short and casual, and offer an out.","Design a database schema for an online merch store.","Compare Gen Z and Millennial marketing strategies for sunglasses."],
|
||||||
|
"history_and_training_disabled": False,
|
||||||
|
"conversation_mode":{"kind":"primary_assistant"},"force_paragen":False,"force_rate_limit":False
|
||||||
|
}
|
||||||
response = requests.post(url, headers=headers, json=payload, stream=stream)
|
response = requests.post(url, headers=headers, json=payload, stream=stream)
|
||||||
# print(response)
|
# print(response)
|
||||||
return response
|
return response
|
||||||
@@ -293,7 +318,6 @@ def replace_complete_citation(text, citations):
|
|||||||
|
|
||||||
return replaced_text, remaining_text, is_potential_citation
|
return replaced_text, remaining_text, is_potential_citation
|
||||||
|
|
||||||
accessable_model_list = ['gpt-4-classic', 'gpt-4-s']
|
|
||||||
# 定义 Flask 路由
|
# 定义 Flask 路由
|
||||||
@app.route('/v1/chat/completions', methods=['POST'])
|
@app.route('/v1/chat/completions', methods=['POST'])
|
||||||
def chat_completions():
|
def chat_completions():
|
||||||
|
|||||||
Reference in New Issue
Block a user