mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-07-31 08:59:51 +00:00
✨ 更新配置选项,添加请求超时和思维链发送功能,兼容Deepseek-R1模型
This commit is contained in:
@ -42,12 +42,14 @@ class ConfigModel(BaseModel):
|
||||
marshoai_enable_plugins: bool = True
|
||||
marshoai_load_builtin_tools: bool = True
|
||||
marshoai_fix_toolcalls: bool = True
|
||||
marshoai_send_thinking: bool = True
|
||||
marshoai_toolset_dir: list = []
|
||||
marshoai_disabled_toolkits: list = []
|
||||
marshoai_azure_endpoint: str = "https://models.inference.ai.azure.com"
|
||||
marshoai_temperature: float | None = None
|
||||
marshoai_max_tokens: int | None = None
|
||||
marshoai_top_p: float | None = None
|
||||
marshoai_timeout: float | None = 50.0
|
||||
marshoai_nickname_limit: int = 16
|
||||
marshoai_additional_image_models: list = []
|
||||
marshoai_tencent_secretid: str | None = None
|
||||
|
@ -42,6 +42,10 @@ marshoai_enable_plugins: true # 是否启用插件功能。
|
||||
|
||||
marshoai_load_builtin_tools: true # 是否加载内置工具。
|
||||
|
||||
marshoai_fix_toolcalls: true # 是否修复工具调用。
|
||||
|
||||
marshoai_send_thinking: true # 是否发送思维链。
|
||||
|
||||
marshoai_nickname_limit: 16 # 昵称长度限制。
|
||||
|
||||
marshoai_toolset_dir: [] # 工具集路径。
|
||||
@ -60,6 +64,7 @@ marshoai_azure_endpoint: "https://models.inference.ai.azure.com" # OpenAI 标准
|
||||
marshoai_temperature: null # 调整生成的多样性,未设置时使用默认值。
|
||||
marshoai_max_tokens: null # 最大生成的token数,未设置时使用默认值。
|
||||
marshoai_top_p: null # 使用的概率采样值,未设置时使用默认值。
|
||||
marshoai_timeout: 50.0 # 请求超时时间。
|
||||
|
||||
marshoai_additional_image_models: [] # 额外的图片模型列表,默认空。
|
||||
|
||||
|
@ -301,7 +301,15 @@ async def marsho(
|
||||
context.append(
|
||||
UserMessage(content=usermsg).as_dict(), target.id, target.private # type: ignore
|
||||
)
|
||||
context.append(choice.message, target.id, target.private)
|
||||
choice_msg_dict = choice.message.to_dict()
|
||||
if "reasoning_content" in choice_msg_dict:
|
||||
if config.marshoai_send_thinking:
|
||||
await UniMessage(
|
||||
"思维链:\n" + choice_msg_dict["reasoning_content"]
|
||||
).send()
|
||||
del choice_msg_dict["reasoning_content"]
|
||||
context.append(choice_msg_dict, target.id, target.private)
|
||||
|
||||
if [target.id, target.private] not in target_list:
|
||||
target_list.append([target.id, target.private])
|
||||
|
||||
@ -402,7 +410,10 @@ async def marsho(
|
||||
UserMessage(content=usermsg).as_dict(), target.id, target.private # type: ignore
|
||||
)
|
||||
# context.append(tool_msg, target.id, target.private)
|
||||
context.append(choice.message, target.id, target.private)
|
||||
choice_msg_dict = choice.message.to_dict()
|
||||
if "reasoning_content" in choice_msg_dict:
|
||||
del choice_msg_dict["reasoning_content"]
|
||||
context.append(choice_msg_dict, target.id, target.private)
|
||||
|
||||
# 发送消息
|
||||
if config.marshoai_enable_richtext_parse:
|
||||
@ -434,7 +445,7 @@ with contextlib.suppress(ImportError): # 优化先不做()
|
||||
user_nickname = nicknames.get(user_id, "")
|
||||
try:
|
||||
if config.marshoai_poke_suffix != "":
|
||||
response = await make_chat(
|
||||
response = await make_chat_openai(
|
||||
client=client,
|
||||
model_name=model_name,
|
||||
msg=[
|
||||
|
@ -124,6 +124,7 @@ async def make_chat_openai(
|
||||
temperature=config.marshoai_temperature,
|
||||
max_tokens=config.marshoai_max_tokens,
|
||||
top_p=config.marshoai_top_p,
|
||||
timeout=config.marshoai_timeout,
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user