mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
feat(models): support gpt-5.5
This commit is contained in:
@@ -30,7 +30,7 @@ from common import const
|
||||
from common.log import logger
|
||||
from config import conf
|
||||
|
||||
DEFAULT_MODEL = const.GPT_41_MINI
|
||||
DEFAULT_MODEL = const.GPT_55
|
||||
DEFAULT_TIMEOUT = 60
|
||||
MAX_TOKENS = 1000
|
||||
COMPRESS_THRESHOLD = 1_048_576 # 1 MB
|
||||
|
||||
@@ -1268,7 +1268,7 @@ class ConfigHandler:
|
||||
const.MINIMAX_M2_7_HIGHSPEED, const.MINIMAX_M2_7, const.MINIMAX_M2_5, const.MINIMAX_M2_1, const.MINIMAX_M2_1_LIGHTNING,
|
||||
const.CLAUDE_4_6_SONNET, const.CLAUDE_4_7_OPUS, const.CLAUDE_4_6_OPUS, const.CLAUDE_4_5_SONNET,
|
||||
const.GEMINI_35_FLASH, const.GEMINI_31_FLASH_LITE_PRE, const.GEMINI_31_PRO_PRE, const.GEMINI_3_FLASH_PRE,
|
||||
const.GPT_54, const.GPT_54_MINI, const.GPT_54_NANO, const.GPT_5, const.GPT_41, const.GPT_4o,
|
||||
const.GPT_55, const.GPT_54, const.GPT_54_MINI, const.GPT_54_NANO, const.GPT_5, const.GPT_41, const.GPT_4o,
|
||||
const.GLM_5_1, const.GLM_5_TURBO, const.GLM_5, const.GLM_4_7,
|
||||
const.QWEN36_PLUS, const.QWEN37_MAX, const.QWEN35_PLUS, const.QWEN3_MAX,
|
||||
const.DOUBAO_SEED_2_PRO, const.DOUBAO_SEED_2_CODE,
|
||||
@@ -1326,7 +1326,7 @@ class ConfigHandler:
|
||||
"api_base_key": "open_ai_api_base",
|
||||
"api_base_default": "https://api.openai.com/v1",
|
||||
"api_base_placeholder": _PLACEHOLDER_V1,
|
||||
"models": [const.GPT_54, const.GPT_54_MINI, const.GPT_54_NANO, const.GPT_5, const.GPT_41, const.GPT_4o],
|
||||
"models": [const.GPT_55, const.GPT_54, const.GPT_54_MINI, const.GPT_54_NANO, const.GPT_5, const.GPT_41, const.GPT_4o],
|
||||
}),
|
||||
("zhipu", {
|
||||
"label": "智谱AI",
|
||||
@@ -1779,9 +1779,10 @@ class ModelsHandler:
|
||||
# OpenAI ordering matches the recommended GPT-5.4 family first, then
|
||||
# GPT-5 and the GPT-4.1/4o backstops.
|
||||
"openai": [
|
||||
const.GPT_55,
|
||||
const.GPT_54,
|
||||
const.GPT_54_MINI,
|
||||
const.GPT_54_NANO,
|
||||
const.GPT_54,
|
||||
const.GPT_5,
|
||||
const.GPT_41,
|
||||
const.GPT_41_MINI,
|
||||
@@ -1991,7 +1992,7 @@ class ModelsHandler:
|
||||
|
||||
# 4. OpenAI raw HTTP
|
||||
if cls._is_real_key(local_config.get("open_ai_api_key", "")):
|
||||
return {"provider": "openai", "model": const.GPT_41_MINI}
|
||||
return {"provider": "openai", "model": const.GPT_55}
|
||||
|
||||
# 5. LinkAI as last resort (only reached when use_linkai is off)
|
||||
if linkai_configured:
|
||||
|
||||
@@ -75,6 +75,7 @@ GPT_5_NANO = "gpt-5-nano"
|
||||
GPT_54 = "gpt-5.4" # GPT-5.4 - Agent recommended model
|
||||
GPT_54_MINI = "gpt-5.4-mini"
|
||||
GPT_54_NANO = "gpt-5.4-nano"
|
||||
GPT_55 = "gpt-5.5" # GPT-5.5 - top-tier (expensive), not default
|
||||
O1 = "o1-preview"
|
||||
O1_MINI = "o1-mini"
|
||||
WHISPER_1 = "whisper-1"
|
||||
@@ -197,7 +198,7 @@ MODEL_LIST = [
|
||||
GPT_4o, GPT_4O_0806, GPT_4o_MINI,
|
||||
GPT_41, GPT_41_MINI, GPT_41_NANO,
|
||||
GPT_5, GPT_5_MINI, GPT_5_NANO,
|
||||
GPT_54, GPT_54_MINI, GPT_54_NANO,
|
||||
GPT_54, GPT_55, GPT_54_MINI, GPT_54_NANO,
|
||||
O1, O1_MINI,
|
||||
|
||||
# GLM (智谱AI)
|
||||
|
||||
@@ -14,7 +14,7 @@ OpenAI 是覆盖最完整的厂商,可同时承担文本对话、视觉理解
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "gpt-5.4",
|
||||
"model": "gpt-5.5",
|
||||
"open_ai_api_key": "YOUR_API_KEY",
|
||||
"open_ai_api_base": "https://api.openai.com/v1"
|
||||
}
|
||||
@@ -22,14 +22,14 @@ OpenAI 是覆盖最完整的厂商,可同时承担文本对话、视觉理解
|
||||
|
||||
| 参数 | 说明 |
|
||||
| --- | --- |
|
||||
| `model` | 与 OpenAI 接口的 [model 参数](https://platform.openai.com/docs/models) 一致,支持 `gpt-5.4`、`gpt-5.4-mini`、`gpt-5.4-nano`、`gpt-5` 系列、`gpt-4.1`、o 系列等;Agent 模式推荐 `gpt-5.4` |
|
||||
| `model` | 与 OpenAI 接口的 [model 参数](https://platform.openai.com/docs/models) 一致,支持 `gpt-5.5`、`gpt-5.4`、`gpt-5.4-mini`、`gpt-5.4-nano`、`gpt-5` 系列、`gpt-4.1`、o 系列等;Agent 模式默认 `gpt-5.5`,追求性价比可改为 `gpt-5.4` |
|
||||
| `open_ai_api_key` | 在 [OpenAI 平台](https://platform.openai.com/api-keys) 创建 |
|
||||
| `open_ai_api_base` | 可选,修改可接入第三方代理 |
|
||||
| `bot_type` | 使用 OpenAI 官方模型时无需填写;通过兼容协议接入厂商模型时需设为 `openai` |
|
||||
|
||||
## 图像理解
|
||||
|
||||
`gpt-5.4`、`gpt-4o`、`gpt-4.1` 等 OpenAI 模型均原生支持视觉,配置 `open_ai_api_key` 后 Agent 的 Vision 工具会自动使用主模型识别图像。若主模型不支持视觉或希望显式指定,可在配置文件中配置:
|
||||
`gpt-5.5`、`gpt-5.4`、`gpt-4o`、`gpt-4.1` 等 OpenAI 模型均原生支持视觉,配置 `open_ai_api_key` 后 Agent 的 Vision 工具会自动使用主模型识别图像。若主模型不支持视觉或希望显式指定,可在配置文件中配置:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -41,7 +41,7 @@ OpenAI 是覆盖最完整的厂商,可同时承担文本对话、视觉理解
|
||||
}
|
||||
```
|
||||
|
||||
支持的 Vision 模型:`gpt-5.4-mini`、`gpt-5.4-nano`、`gpt-5.4`、`gpt-5`、`gpt-4.1`、`gpt-4.1-mini`、`gpt-4o`。
|
||||
支持的 Vision 模型:`gpt-5.5`、`gpt-5.4`、`gpt-5.4-mini`、`gpt-5.4-nano`、`gpt-5`、`gpt-4.1`、`gpt-4.1-mini`、`gpt-4o`。
|
||||
|
||||
## 图像生成
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ChatGPTBot(Bot, OpenAIImage, OpenAICompatibleBot):
|
||||
"timeout": conf().get("request_timeout", None), # 重试超时时间,在这个时间内,将会自动重试
|
||||
}
|
||||
# 部分模型暂不支持一些参数,特殊处理
|
||||
if conf_model in [const.O1, const.O1_MINI, const.GPT_5, const.GPT_5_MINI, const.GPT_5_NANO]:
|
||||
if conf_model in [const.O1, const.O1_MINI, const.GPT_5, const.GPT_5_MINI, const.GPT_5_NANO, const.GPT_55]:
|
||||
remove_keys = ["temperature", "top_p", "frequency_penalty", "presence_penalty"]
|
||||
for key in remove_keys:
|
||||
self.args.pop(key, None) # 如果键不存在,使用 None 来避免抛出错、
|
||||
|
||||
@@ -89,8 +89,9 @@ class OpenAICompatibleBot:
|
||||
messages[0] = {"role": "system", "content": system_prompt}
|
||||
|
||||
# Build request parameters
|
||||
model_name = kwargs.get("model", api_config.get('model', 'gpt-5.4'))
|
||||
request_params = {
|
||||
"model": kwargs.get("model", api_config.get('model', 'gpt-3.5-turbo')),
|
||||
"model": model_name,
|
||||
"messages": messages,
|
||||
"temperature": kwargs.get("temperature", api_config.get('default_temperature', 0.9)),
|
||||
"top_p": kwargs.get("top_p", api_config.get('default_top_p', 1.0)),
|
||||
@@ -98,6 +99,10 @@ class OpenAICompatibleBot:
|
||||
"presence_penalty": kwargs.get("presence_penalty", api_config.get('default_presence_penalty', 0.0)),
|
||||
"stream": stream
|
||||
}
|
||||
# GPT-5 / GPT-5.5 / o1 series only accept default temperature/top_p and reject penalty params
|
||||
if model_name in ("gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5.5", "o1", "o1-mini"):
|
||||
for key in ("temperature", "top_p", "frequency_penalty", "presence_penalty"):
|
||||
request_params.pop(key, None)
|
||||
|
||||
# Add max_tokens if specified
|
||||
if kwargs.get("max_tokens"):
|
||||
|
||||
Reference in New Issue
Block a user