diff --git a/nonebot_plugin_marshoai/marsho.py b/nonebot_plugin_marshoai/marsho.py index b127aec..d12e0cf 100644 --- a/nonebot_plugin_marshoai/marsho.py +++ b/nonebot_plugin_marshoai/marsho.py @@ -449,7 +449,11 @@ with contextlib.suppress(ImportError): # 优化先不做() client=client, model_name=model_name, msg=[ - get_prompt(), + ( + get_prompt() + if model_name.lower() not in NO_SYSPROMPT_MODELS + else None + ), UserMessage( content=f"*{user_nickname}{config.marshoai_poke_suffix}" ), diff --git a/nonebot_plugin_marshoai/util.py b/nonebot_plugin_marshoai/util.py index a4a04d4..904c9ee 100755 --- a/nonebot_plugin_marshoai/util.py +++ b/nonebot_plugin_marshoai/util.py @@ -14,7 +14,7 @@ from nonebot.log import logger from nonebot_plugin_alconna import Image as ImageMsg from nonebot_plugin_alconna import Text as TextMsg from nonebot_plugin_alconna import UniMessage -from openai import AsyncOpenAI +from openai import AsyncOpenAI, NotGiven from zhDateTime import DateTime from .config import config @@ -25,6 +25,8 @@ nickname_json = None # 记录昵称 praises_json = None # 记录夸赞名单 loaded_target_list = [] # 记录已恢复备份的上下文的列表 +NOT_GIVEN = NotGiven() + # 时间参数相关 if config.marshoai_enable_time_prompt: _weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"] @@ -141,13 +143,13 @@ async def make_chat_openai( model_name: 指定AI模型名 tools: 工具列表 """ - return await client.chat.completions.create( + return await client.chat.completions.create( # type: ignore messages=msg, model=model_name, - tools=tools, - temperature=config.marshoai_temperature, - max_tokens=config.marshoai_max_tokens, - top_p=config.marshoai_top_p, + tools=tools or NOT_GIVEN, + temperature=config.marshoai_temperature or NOT_GIVEN, + max_tokens=config.marshoai_max_tokens or NOT_GIVEN, + top_p=config.marshoai_top_p or NOT_GIVEN, timeout=config.marshoai_timeout, )