添加 System-As-User 提示词配置,更新相关文档

This commit is contained in:
2025-02-15 13:47:21 +08:00
parent 50567e1f57
commit aef1f0be5d
5 changed files with 23 additions and 10 deletions

View File

@@ -28,6 +28,8 @@ class ConfigModel(BaseModel):
"当主人给你图片作为问题,并且你确实可以处理图片时,你必须以猫娘的说话方式进行回答,"
"当主人想要你回复一些有关 LaTeX 公式的时候,你切记一定不可以在公式中包含非 ASCII 字符。"
)
marshoai_sysasuser_prompt: str = "好的喵~"
marshoai_enable_sysasuser_prompt: bool = False
marshoai_additional_prompt: str = ""
marshoai_poke_suffix: str = "揉了揉你的猫耳"
marshoai_enable_richtext_parse: bool = True
@@ -146,6 +148,7 @@ if config.marshoai_use_yaml_config:
config = ConfigModel(**yaml_config)
else:
logger.info(
"MarshoAI 支持新的 YAML 配置系统,若要使用,请将 MARSHOAI_USE_YAML_CONFIG 配置项设置为 true。"
)
# logger.info(
# "MarshoAI 支持新的 YAML 配置系统,若要使用,请将 MARSHOAI_USE_YAML_CONFIG 配置项设置为 true。"
# )
pass

View File

@@ -303,7 +303,7 @@ async def marsho(
# Sprint(choice)
# 当tool_calls非空时将finish_reason设置为TOOL_CALLS
if choice.message.tool_calls != None and config.marshoai_fix_toolcalls:
choice.finish_reason = CompletionsFinishReason.TOOL_CALLS
choice.finish_reason = "tool_calls"
logger.info(f"完成原因:{choice.finish_reason}")
if choice.finish_reason == CompletionsFinishReason.STOPPED:
# 当对话成功时将dict的上下文添加到上下文类中

View File

@@ -9,7 +9,7 @@ import aiofiles # type: ignore
import httpx
import nonebot_plugin_localstore as store
from azure.ai.inference.aio import ChatCompletionsClient
from azure.ai.inference.models import SystemMessage
from azure.ai.inference.models import AssistantMessage, SystemMessage, UserMessage
from nonebot import get_driver
from nonebot.log import logger
from nonebot_plugin_alconna import Image as ImageMsg
@@ -274,10 +274,16 @@ def get_prompt(model: str) -> List[Dict[str, Any]]:
marsho_prompt = config.marshoai_prompt
sysprompt_content = marsho_prompt + prompts
prompt_list: List[Dict[str, Any]] = []
if model not in OPENAI_NEW_MODELS:
prompt_list += [SystemMessage(content=sysprompt_content).as_dict()]
if not config.marshoai_enable_sysasuser_prompt:
if model not in OPENAI_NEW_MODELS:
prompt_list += [SystemMessage(content=sysprompt_content).as_dict()]
else:
prompt_list += [DeveloperMessage(content=sysprompt_content).as_dict()]
else:
prompt_list += [DeveloperMessage(content=sysprompt_content).as_dict()]
prompt_list += [UserMessage(content=sysprompt_content).as_dict()]
prompt_list += [
AssistantMessage(content=config.marshoai_sysasuser_prompt).as_dict()
]
return prompt_list