mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-02-07 21:46:10 +08:00
✨ 优化参数处理逻辑,添加默认值支持;更新天气获取函数的返回信息
This commit is contained in:
parent
df8bc01178
commit
5fc4140cf7
@ -131,6 +131,12 @@ class Caller:
|
||||
param.annotation, Caller
|
||||
):
|
||||
kwargs[name] = self
|
||||
|
||||
# 检查形参是否有默认值或传入,若没有则用parameters中的默认值填充
|
||||
for name, param in sig.parameters.items():
|
||||
if name not in kwargs:
|
||||
kwargs[name] = self._parameters.get(name, param.default)
|
||||
|
||||
return await self.func(*args, **kwargs)
|
||||
|
||||
|
||||
|
@ -32,14 +32,14 @@ async def fortune_telling(age: int, name: str, gender: str) -> str:
|
||||
@on_function_call(description="获取一个地点未来一段时间的天气").params(
|
||||
location=String(description="地点名称,可以是城市名、地区名等"),
|
||||
days=Integer(description="天数", minimum=1, maximum=30),
|
||||
unit=String(enum=["摄氏度", "华氏度"], description="温度单位"),
|
||||
unit=String(enum=["摄氏度", "华氏度"], description="温度单位", default="摄氏度"),
|
||||
)
|
||||
async def get_weather(location: str, days: int, unit: str) -> str:
|
||||
"""获取一个地点未来一段时间的天气"""
|
||||
|
||||
# 进行一系列获取天气操作...
|
||||
|
||||
return f"{location}未来{days}天的天气信息..."
|
||||
return f"{location}未来{days}天的天气很好,全都是晴天,温度是34"
|
||||
|
||||
|
||||
@on_function_call(description="获取设备物理地理位置")
|
||||
|
Loading…
x
Reference in New Issue
Block a user