diff --git a/README.md b/README.md index cacb93f6..253a2d1d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ _✨ 使用 OpenAI 标准格式 API 的聊天机器人插件 ✨_ ## 📖 介绍 -通过调用 OpenAI 标准格式 API(例如由 Azure OpenAI 驱动,GitHub Models 提供访问的生成式 AI 推理 API) 来实现聊天的插件。 +通过调用 OpenAI 标准格式 API(例如 GitHub Models API) 来实现聊天的插件。 插件内置了猫娘小棉(Marsho)的人物设定,可以进行可爱的聊天! *谁不喜欢回复消息快又可爱的猫娘呢?* **对 OneBot 以外的适配器与非 GitHub Models API的支持未经过完全验证。** diff --git a/nonebot_plugin_marshoai/plugins/twisuki_petcat/__init__.py b/nonebot_plugin_marshoai/plugins/twisuki_petcat/__init__.py index 02123ca2..b6573dc3 100644 --- a/nonebot_plugin_marshoai/plugins/twisuki_petcat/__init__.py +++ b/nonebot_plugin_marshoai/plugins/twisuki_petcat/__init__.py @@ -1,10 +1,6 @@ -from nonebot_plugin_marshoai.plugin import ( - Integer, - Parameter, - PluginMetadata, - String, - on_function_call, -) +from nonebot_plugin_marshoai.plugin import PluginMetadata + +from .pc_cat import * __marsho_meta__ = PluginMetadata( name="养猫插件", diff --git a/nonebot_plugin_marshoai/plugins/twisuki_petcat/pc_cat.py b/nonebot_plugin_marshoai/plugins/twisuki_petcat/pc_cat.py index 069efed9..adfaf1e9 100644 --- a/nonebot_plugin_marshoai/plugins/twisuki_petcat/pc_cat.py +++ b/nonebot_plugin_marshoai/plugins/twisuki_petcat/pc_cat.py @@ -1 +1,33 @@ # 主交互 + +from datetime import datetime + +from nonebot_plugin_marshoai.plugin import String, on_function_call + +from .pc_token import ERROR_DICT, dict_to_token, token_to_dict + + +@on_function_call(description="创建一个新的猫对象(养一只新猫)").params( + name=String(description="猫的名字") +) +async def create_cat(name: str) -> str: + cat_data = { + "name": name, + "age": ERROR_DICT["age"], + "type": ERROR_DICT["type"], + "health": ERROR_DICT["health"], + "saturation": ERROR_DICT["saturation"], + "energy": ERROR_DICT["energy"], + "skill": ERROR_DICT["skill"], + "date": (datetime(2025, 1, 1) - datetime.now()).days, + } + token = dict_to_token(cat_data) + return f"猫对象创建成功,Token: {token}" + + +@on_function_call(description="查询猫对象信息").params( + token=String(description="猫对象的Token(是一串类似base64的字符串)") +) +async def query_cat(token: str) -> str: + cat_data = token_to_dict(token) + return f"猫的名字: {cat_data['name']}, 年龄: {cat_data['age']}, 种类: {cat_data['type']}, 生命值: {cat_data['health']}, 饱食度: {cat_data['saturation']}, 活力值: {cat_data['energy']}, 技能: {cat_data['skill']}, 日期: {cat_data['date']}"