6 Commits

Author SHA1 Message Date
Yanyutin753
10782fbe1f 支持最新的gpt-4-o模型 2024-05-14 13:07:19 +08:00
Clivia
8a9932b18d 优化部署说明 2024-04-06 00:33:54 +08:00
Clivia
4b706bfb8d 更新部署说明 2024-04-06 00:30:26 +08:00
Clivia
7a1d7541bf 优化部署说明 2024-04-05 17:44:28 +08:00
Clivia
39d394e28b 优化部署说明 2024-04-05 01:16:30 +08:00
Clivia
816e78ab81 适配调用team对话,提供查询ChatGPT-Account-ID的/getAccountID接口 2024-04-04 22:10:38 +08:00
3 changed files with 55 additions and 15 deletions

View File

@@ -90,11 +90,14 @@
4. gpt-3.5-turbo
## Docker-Compose 部署
## 部署说明
<details>
### Docker-Compose 部署
仓库内已包含相关文件和目录,拉到本地后修改 docker-compose.yml 文件里的环境变量后运行`docker-compose up -d`即可。
## config.json 变量说明:
### config.json 变量说明:
- `log_level`: 用于设置日志等级,可选值为:`DEBUG``INFO``WARNING``ERROR`,默认为 `DEBUG`
@@ -148,7 +151,7 @@ PS. 注意arkose_urls中的地址需要支持PandoraNext的Arkose Token获取
- `enableOai`:用于设置是否使用官网通过refresh_token刷新access_token仅在 `enableOai``true` 时生效。
- `oaiFree_refreshToAccess_Url`:用于设置使用oaiFree来进行使用refresh_token刷新access_token,enableOai为false的时候必填
- `oaifree_refreshToAccess_Url`:用于设置使用oaiFree来进行使用refresh_token刷新access_token,enableOai为false的时候必填
- 默认为"https://token.oaifree.com/api/auth/refresh"
- `redis`
@@ -161,7 +164,7 @@ PS. 注意arkose_urls中的地址需要支持PandoraNext的Arkose Token获取
- `db`: Redis的数据库默认0如有特殊需求你可以将此值设置为其他数据库
## GPTS配置说明
### GPTS配置说明
如果需要使用 GPTS需要修改 `gpts.json` 文件其中每个对象的key即为调用对应 GPTS 的时候使用的模型名称,而 `id` 则为对应的模型id`id` 对应每个 GPTS 的链接的后缀。配置多个GPTS的时候用逗号隔开。
@@ -182,7 +185,7 @@ PS. 注意arkose_urls中的地址需要支持PandoraNext的Arkose Token获取
注意:使用该配置的时候需要保证正确填写 `docker-compose.yml` 的环境变量 `KEY_FOR_GPTS_INFO`,同时该变量设置的 `key` 允许访问所有配置的 GPTS。
## 绘图接口使用说明
### 绘图接口使用说明
接口URI`/v1/images/generations`
@@ -219,7 +222,7 @@ PS. 注意arkose_urls中的地址需要支持PandoraNext的Arkose Token获取
}
```
## 文件识别接口使用说明
### 文件识别接口使用说明
调用方式同官方 `gpt-4-vision-preview` API
@@ -318,8 +321,18 @@ PS. 注意arkose_urls中的地址需要支持PandoraNext的Arkose Token获取
}
}
```
### 获取ChatGPT-Account-ID接口
## 示例
接口URI`/getAccountID`
请求方式:`POST`
```
请求头加上
AuthorizationBearer refresh_token 或 access_token
```
### 示例
以ChatGPT-Next-Web项目的docker-compose部署为例这里提供一个简单的部署配置文件示例
@@ -336,6 +349,8 @@ services:
- CUSTOM_MODELS=+gpt-4-s,+gpt-4-mobile,+<gpts.json 中的模型名>
```
</details>
## 功能演示
<details>
@@ -378,9 +393,6 @@ services:
> * 本项目只提供转发接口🥰
> * 开源项目不易,请点个星星吧!!!
### 新增群聊,点了⭐️可以进群讨论部署,我把你们拉进群,无广,广子踢掉
<img src="https://github.com/Yanyutin753/PandoraNext-TokensTool/assets/132346501/6544e8ed-6673-48f9-95a6-c13255acbab1" width="300" height="300">
## Sponsor
### 如果你觉得我的开源项目对你有帮助,可以赞助我一杯咖啡嘛,十分感谢!!!

View File

@@ -10,6 +10,7 @@
"gpt_4_s_new_name": "gpt-4-s",
"gpt_4_mobile_new_name": "gpt-4-mobile,dall-e-3",
"gpt_3_5_new_name": "gpt-3.5-turbo",
"gpt_4_o_new_name": "gpt-4-o",
"need_delete_conversation_after_response": "true",
"use_oaiusercontent_url": "false",
"custom_arkose_url": "false",

37
main.py
View File

@@ -51,6 +51,7 @@ API_PREFIX = CONFIG.get('backend_container_api_prefix', '')
GPT_4_S_New_Names = CONFIG.get('gpt_4_s_new_name', 'gpt-4-s').split(',')
GPT_4_MOBILE_NEW_NAMES = CONFIG.get('gpt_4_mobile_new_name', 'gpt-4-mobile').split(',')
GPT_3_5_NEW_NAMES = CONFIG.get('gpt_3_5_new_name', 'gpt-3.5-turbo').split(',')
GPT_4_O_NEW_NAMES = CONFIG.get('gpt_4_o_new_name', 'gpt-4-o').split(',')
BOT_MODE = CONFIG.get('bot_mode', {})
BOT_MODE_ENABLED = BOT_MODE.get('enabled', 'false').lower() == 'true'
@@ -335,9 +336,9 @@ scheduler.start()
# PANDORA_UPLOAD_URL = 'files.pandoranext.com'
VERSION = '0.7.9.1'
VERSION = '0.7.9.2'
# VERSION = 'test'
UPDATE_INFO = '适配调用team对话,提供查询ChatGPT-Account-ID的/getAccountID接口'
UPDATE_INFO = '支持最新的gpt-4-o模型'
# UPDATE_INFO = '【仅供临时测试使用】 '
with app.app_context():
@@ -448,7 +449,11 @@ with app.app_context():
"name": name.strip(),
"ori_name": "gpt-3.5-turbo"
})
for name in GPT_4_O_NEW_NAMES:
gpts_configurations.append({
"name": name.strip(),
"ori_name": "gpt-4-o"
})
logger.info(f"GPTS 配置信息")
# 加载配置并添加到全局列表
@@ -719,7 +724,7 @@ def send_text_prompt_and_get_response(messages, api_key, account_id, stream, mod
message_id = str(uuid.uuid4())
content = message.get("content")
if isinstance(content, list) and ori_model_name != 'gpt-3.5-turbo':
if isinstance(content, list) and ori_model_name not in ['gpt-3.5-turbo', 'gpt-4-o']:
logger.debug(f"gpt-vision 调用")
new_parts = []
attachments = []
@@ -879,6 +884,28 @@ def send_text_prompt_and_get_response(messages, api_key, account_id, stream, mod
"force_paragen": False,
"force_rate_limit": False
}
elif ori_model_name == 'gpt-4-o':
payload = {
# 构建 payload
"action": "next",
"messages": formatted_messages,
"parent_message_id": str(uuid.uuid4()),
"model": "auto",
"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
}
elif 'gpt-4-gizmo-' in model:
payload = generate_gpts_payload(model, formatted_messages)
if not payload:
@@ -913,7 +940,7 @@ def send_text_prompt_and_get_response(messages, api_key, account_id, stream, mod
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 ori_model_name not in ['gpt-3.5-turbo', 'gpt-4-o']:
if CUSTOM_ARKOSE:
token = get_token()
payload["arkose_token"] = token