diff --git a/bot/chatgpt/chat_gpt_bot.py b/bot/chatgpt/chat_gpt_bot.py index 348d5fa..4f97fc2 100644 --- a/bot/chatgpt/chat_gpt_bot.py +++ b/bot/chatgpt/chat_gpt_bot.py @@ -44,12 +44,13 @@ class ChatGPTBot(Bot, OpenAIImage): "request_timeout": conf().get("request_timeout", None), # 请求超时时间,openai接口默认设置为600,对于难问题一般需要较长时间 "timeout": conf().get("request_timeout", None), # 重试超时时间,在这个时间内,将会自动重试 } - # o1相关模型固定了部分参数,暂时去掉 - if conf_model in [const.O1, const.O1_MINI]: - self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or const.O1_MINI) + # 部分模型暂不支持一些参数,特殊处理 + if conf_model in [const.O1, const.O1_MINI, const.GPT_5, const.GPT_5_MINI, const.GPT_5_NANO]: remove_keys = ["temperature", "top_p", "frequency_penalty", "presence_penalty"] for key in remove_keys: - self.args.pop(key, None) # 如果键不存在,使用 None 来避免抛出错误 + self.args.pop(key, None) # 如果键不存在,使用 None 来避免抛出错、 + if conf_model in [const.O1, const.O1_MINI]: # o1系列模型不支持系统提示词,使用文心模型的session + self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or const.O1_MINI) def reply(self, query, context=None): # acquire reply content diff --git a/bot/chatgpt/chat_gpt_session.py b/bot/chatgpt/chat_gpt_session.py index b5fc6fd..5f524a3 100644 --- a/bot/chatgpt/chat_gpt_session.py +++ b/bot/chatgpt/chat_gpt_session.py @@ -67,7 +67,7 @@ def num_tokens_from_messages(messages, model): elif model in ["gpt-4-0314", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0613", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-16k-0613", "gpt-35-turbo-16k", "gpt-4-turbo-preview", "gpt-4-1106-preview", const.GPT4_TURBO_PREVIEW, const.GPT4_VISION_PREVIEW, const.GPT4_TURBO_01_25, - const.GPT_4o, const.GPT_4O_0806, const.GPT_4o_MINI, const.LINKAI_4o, const.LINKAI_4_TURBO]: + const.GPT_4o, const.GPT_4O_0806, const.GPT_4o_MINI, const.LINKAI_4o, const.LINKAI_4_TURBO, const.GPT_5, const.GPT_5_MINI, const.GPT_5_NANO]: return num_tokens_from_messages(messages, model="gpt-4") elif model.startswith("claude-3"): return num_tokens_from_messages(messages, model="gpt-3.5-turbo") diff --git a/common/const.py b/common/const.py index f8d487a..16c450e 100644 --- a/common/const.py +++ b/common/const.py @@ -41,6 +41,10 @@ GPT_41 = "gpt-4.1" GPT_41_MINI = "gpt-4.1-mini" GPT_41_NANO = "gpt-4.1-nano" +GPT_5 = "gpt-5" +GPT_5_MINI = "gpt-5-mini" +GPT_5_NANO = "gpt-5-nano" + O1 = "o1-preview" O1_MINI = "o1-mini" @@ -102,6 +106,7 @@ MODELSCOPE_MODEL_LIST = ["LLM-Research/c4ai-command-r-plus-08-2024","mistralai/M MODEL_LIST = [ GPT35, GPT35_0125, GPT35_1106, "gpt-3.5-turbo-16k", GPT_41, GPT_41_MINI, GPT_41_NANO, O1, O1_MINI, GPT_4o, GPT_4O_0806, GPT_4o_MINI, GPT4_TURBO, GPT4_TURBO_PREVIEW, GPT4_TURBO_01_25, GPT4_TURBO_11_06, GPT4, GPT4_32k, GPT4_06_13, GPT4_32k_06_13, + GPT_5, GPT_5_MINI, GPT_5_NANO, WEN_XIN, WEN_XIN_4, XUNFEI, ZHIPU_AI, GLM_4, GLM_4_PLUS, GLM_4_flash, GLM_4_LONG, GLM_4_ALLTOOLS, GLM_4_0520, GLM_4_AIR, GLM_4_AIRX,