diff --git a/docs/en/start/install.md b/docs/en/start/install.md index afa352d6..a4dfa3a9 100644 --- a/docs/en/start/install.md +++ b/docs/en/start/install.md @@ -117,6 +117,7 @@ Add options in the `.env` file from the diagram below in nonebot2 project. | MARSHOAI_DEFAULT_MODEL | `str` | `gpt-4o-mini` | The default model of Marsho | | MARSHOAI_PROMPT | `str` | Catgirl Marsho's character prompt | Marsho's basic system prompt **※Some models(o1 and so on) don't support it** | | MARSHOAI_ADDITIONAL_PROMPT | `str` | | Marsho's external system prompt | +| MARSHOAI_ENFORCE_NICKNAME | `bool` | `true` | Enforce user to set nickname or not | | MARSHOAI_POKE_SUFFIX | `str` | `揉了揉你的猫耳` | When double click Marsho who connected to OneBot adapter, the chat content. When it's empty string, double click function is off. Such as, the default content is `*[昵称]揉了揉你的猫耳。` | | MARSHOAI_AZURE_ENDPOINT | `str` | `https://models.inference.ai.azure.com` | OpenAI standard API | | MARSHOAI_TEMPERATURE | `float` | `null` | temperature parameter | diff --git a/docs/zh/start/install.md b/docs/zh/start/install.md index 12ba51ef..ddd892f5 100644 --- a/docs/zh/start/install.md +++ b/docs/zh/start/install.md @@ -119,6 +119,7 @@ title: 安装 | MARSHOAI_DEFAULT_MODEL | `str` | `gpt-4o-mini` | Marsho 默认调用的模型 | | MARSHOAI_PROMPT | `str` | 猫娘 Marsho 人设提示词 | Marsho 的基本系统提示词 **※部分模型(o1等)不支持系统提示词。** | | MARSHOAI_ADDITIONAL_PROMPT | `str` | | Marsho 的扩展系统提示词 | +| MARSHOAI_ENFORCE_NICKNAME | `bool` | `true` | 是否强制用户设置昵称 | | MARSHOAI_POKE_SUFFIX | `str` | `揉了揉你的猫耳` | 对 Marsho 所连接的 OneBot 用户进行双击戳一戳时,构建的聊天内容。此配置项为空字符串时,戳一戳响应功能会被禁用。例如,默认值构建的聊天内容将为`*[昵称]揉了揉你的猫耳。` | | MARSHOAI_AZURE_ENDPOINT | `str` | `https://models.inference.ai.azure.com` | OpenAI 标准格式 API 端点 | | MARSHOAI_TEMPERATURE | `float` | `null` | 推理生成多样性(温度)参数 | diff --git a/nonebot_plugin_marshoai/azure.py b/nonebot_plugin_marshoai/azure.py index af946cdc..4384eb4e 100644 --- a/nonebot_plugin_marshoai/azure.py +++ b/nonebot_plugin_marshoai/azure.py @@ -278,9 +278,14 @@ async def marsho( # 用户名无法获取,暂时注释 # user_nickname = event.sender.nickname # 未设置昵称时获取用户名 # nickname_prompt = f"\n*此消息的说话者:{user_nickname}" + if config.marshoai_enforce_nickname: + await UniMessage( + "※你未设置自己的昵称。你**必须**使用「nickname [昵称]」命令设置昵称后才能进行对话。" + ).send() + return if config.marshoai_enable_nickname_tip: await UniMessage( - "*你未设置自己的昵称。推荐使用'nickname [昵称]'命令设置昵称来获得个性化(可能)回答。" + "※你未设置自己的昵称。推荐使用「nickname [昵称]」命令设置昵称来获得个性化(可能)回答。" ).send() is_support_image_model = ( diff --git a/nonebot_plugin_marshoai/config.py b/nonebot_plugin_marshoai/config.py index 361245fd..7a919027 100644 --- a/nonebot_plugin_marshoai/config.py +++ b/nonebot_plugin_marshoai/config.py @@ -34,8 +34,9 @@ class ConfigModel(BaseModel): marshoai_single_latex_parse: bool = False marshoai_enable_nickname_tip: bool = True marshoai_enable_support_image_tip: bool = True + marshoai_enforce_nickname: bool = True marshoai_enable_praises: bool = True - marshoai_enable_time_prompt: bool = True + # marshoai_enable_time_prompt: bool = True marshoai_enable_tools: bool = False marshoai_enable_plugins: bool = True marshoai_load_builtin_tools: bool = True diff --git a/nonebot_plugin_marshoai/config_example.yaml b/nonebot_plugin_marshoai/config_example.yaml index dba5d3c0..da9a8550 100644 --- a/nonebot_plugin_marshoai/config_example.yaml +++ b/nonebot_plugin_marshoai/config_example.yaml @@ -32,6 +32,8 @@ marshoai_enable_nickname_tip: true # 是否启用昵称提示。 marshoai_enable_support_image_tip: true # 是否启用支持图片提示。 +marshoai_enforce_nickname: true # 是否强制要求设定昵称。 + marshoai_enable_praises: true # 是否启用夸赞名单功能。 marshoai_enable_tools: false # 是否启用工具支持。 diff --git a/nonebot_plugin_marshoai/dev.py b/nonebot_plugin_marshoai/dev.py index 0f114348..ef92a84d 100644 --- a/nonebot_plugin_marshoai/dev.py +++ b/nonebot_plugin_marshoai/dev.py @@ -32,7 +32,7 @@ driver = get_driver() function_call = on_alconna( command=Alconna( - "marsho-function-call", + f"{config.marshoai_default_name}.funccall", Subcommand( "call", Args["function_name", str]["kwargs", MultiVar(str), []], diff --git a/nonebot_plugin_marshoai/plugins/marshoai_memory/__init__.py b/nonebot_plugin_marshoai/plugins/marshoai_memory/__init__.py index 98cae22e..7cefa45a 100644 --- a/nonebot_plugin_marshoai/plugins/marshoai_memory/__init__.py +++ b/nonebot_plugin_marshoai/plugins/marshoai_memory/__init__.py @@ -20,8 +20,7 @@ memory_path = get_plugin_data_file("memory.json") if not Path(memory_path).exists(): with open(memory_path, "w", encoding="utf-8") as f: json.dump({}, f, ensure_ascii=False, indent=4) -print(memory_path) -# +# print(memory_path) @on_function_call(description="存储记忆内容").params( @@ -43,9 +42,9 @@ async def write_memory(memory: str, user_id: str): return "记忆已经保存啦~" -@on_function_call(description="读取记忆内容").params( - user_id=String(description="你想读取记忆的人的id") -) +@on_function_call( + description="当用户与你发起对话时,你需要回忆有关他的一切,因此调用此函数读取记忆内容" +).params(user_id=String(description="你想读取记忆的人的id")) async def read_memory(user_id: str): with open(memory_path, "r", encoding="utf-8") as f: memory_data = json.load(f) diff --git a/nonebot_plugin_marshoai/plugins/random_number_generator.py b/nonebot_plugin_marshoai/plugins_test/random_number_generator.py similarity index 100% rename from nonebot_plugin_marshoai/plugins/random_number_generator.py rename to nonebot_plugin_marshoai/plugins_test/random_number_generator.py diff --git a/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py b/nonebot_plugin_marshoai/plugins_test/snowykami_testplugin/__init__.py similarity index 100% rename from nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py rename to nonebot_plugin_marshoai/plugins_test/snowykami_testplugin/__init__.py diff --git a/nonebot_plugin_marshoai/plugins/weather_demo.py b/nonebot_plugin_marshoai/plugins_test/weather_demo.py similarity index 100% rename from nonebot_plugin_marshoai/plugins/weather_demo.py rename to nonebot_plugin_marshoai/plugins_test/weather_demo.py