mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-02-07 12:16:12 +08:00
✨ 更新函数调用模型,添加同步函数类型支持;重构函数信息获取逻辑;新增示例测试用例
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 38s
Pre-commit checks / pre-commit (3.11) (push) Successful in 2m40s
Pre-commit checks / pre-commit (3.10) (push) Successful in 3m19s
Pre-commit checks / pre-commit (3.12) (push) Successful in 3m19s
Pre-commit checks / pre-commit (3.13) (push) Successful in 3m23s
Pytest API Testing / Pytest (3.11) (push) Failing after 2m10s
Pytest API Testing / Pytest (3.10) (push) Failing after 2m51s
Pytest API Testing / Pytest (3.12) (push) Failing after 2m46s
Pytest API Testing / Pytest (3.13) (push) Failing after 2m39s
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 38s
Pre-commit checks / pre-commit (3.11) (push) Successful in 2m40s
Pre-commit checks / pre-commit (3.10) (push) Successful in 3m19s
Pre-commit checks / pre-commit (3.12) (push) Successful in 3m19s
Pre-commit checks / pre-commit (3.13) (push) Successful in 3m23s
Pytest API Testing / Pytest (3.11) (push) Failing after 2m10s
Pytest API Testing / Pytest (3.10) (push) Failing after 2m51s
Pytest API Testing / Pytest (3.12) (push) Failing after 2m46s
Pytest API Testing / Pytest (3.13) (push) Failing after 2m39s
This commit is contained in:
parent
2229a60a05
commit
52046ba032
@ -3,7 +3,7 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .typing import ASYNC_FUNCTION_CALL_FUNC
|
||||
from .typing import ASYNC_FUNCTION_CALL_FUNC, FUNCTION_CALL_FUNC
|
||||
|
||||
|
||||
class PluginMetadata(BaseModel):
|
||||
@ -114,7 +114,7 @@ class FunctionCall(BaseModel):
|
||||
"""函数描述 这个函数用于获取天气信息"""
|
||||
arguments: dict[str, FunctionCallArgument]
|
||||
"""函数参数信息"""
|
||||
function: ASYNC_FUNCTION_CALL_FUNC
|
||||
function: FUNCTION_CALL_FUNC
|
||||
"""函数对象"""
|
||||
|
||||
class Config:
|
||||
|
@ -2,17 +2,17 @@
|
||||
"""
|
||||
|
||||
import inspect
|
||||
from typing import Any, Callable, Coroutine, TypeAlias
|
||||
|
||||
from nonebot import logger
|
||||
|
||||
from nonebot_plugin_marshoai.plugin.utils import is_coroutine_callable
|
||||
|
||||
from .models import FunctionCall, FunctionCallArgument
|
||||
from .typing import (
|
||||
ASYNC_FUNCTION_CALL_FUNC,
|
||||
FUNCTION_CALL_FUNC,
|
||||
SYNC_FUNCTION_CALL_FUNC,
|
||||
)
|
||||
from .utils import is_coroutine_callable
|
||||
|
||||
_loaded_functions: dict[str, FUNCTION_CALL_FUNC] = {}
|
||||
|
||||
@ -42,21 +42,21 @@ def function_call(*funcs: FUNCTION_CALL_FUNC) -> None:
|
||||
Returns:
|
||||
str: 函数定义信息
|
||||
"""
|
||||
for func in funcs:
|
||||
function_call = get_function_info(func)
|
||||
# TODO: 注册函数
|
||||
# for func in funcs:
|
||||
# function_call = get_function_info(func)
|
||||
# # TODO: 注册函数
|
||||
|
||||
|
||||
def get_function_info(func: FUNCTION_CALL_FUNC):
|
||||
"""获取函数信息
|
||||
# def get_function_info(func: FUNCTION_CALL_FUNC) -> FunctionCall:
|
||||
# """获取函数信息
|
||||
|
||||
Args:
|
||||
func: 函数对象
|
||||
# Args:
|
||||
# func: 函数对象
|
||||
|
||||
Returns:
|
||||
FunctionCall: 函数信息对象模型
|
||||
"""
|
||||
name = func.__name__
|
||||
description = func.__doc__
|
||||
logger.info(f"注册函数: {name} {description}")
|
||||
# TODO: 获取函数参数信息
|
||||
# Returns:
|
||||
# FunctionCall: 函数信息对象模型
|
||||
# """
|
||||
# description = func.__doc__
|
||||
# # TODO: 获取函数参数信息
|
||||
# parameters = {}
|
||||
# pass
|
||||
|
@ -20,7 +20,8 @@ dependencies = [
|
||||
"pyyaml>=6.0.2",
|
||||
"psutil>=6.1.0",
|
||||
"beautifulsoup4>=4.12.3",
|
||||
"pydantic>=2.10.3"
|
||||
"pydantic>=2.10.3",
|
||||
"litedoc>=0.1.0.dev20241214103915"
|
||||
|
||||
]
|
||||
license = { text = "MIT, Mulan PSL v2" }
|
||||
@ -65,3 +66,6 @@ dev = [
|
||||
"black>=24.10.0",
|
||||
"litedoc>=0.1.0.dev20240906203154",
|
||||
]
|
||||
test = [
|
||||
"nonebug>=0.4.3",
|
||||
]
|
||||
|
20
tests/test_plugin.py
Normal file
20
tests/test_plugin.py
Normal file
@ -0,0 +1,20 @@
|
||||
def example_function(num: int, text: str, is_a: bool) -> str:
|
||||
"""这是一个示例描述
|
||||
|
||||
Args:
|
||||
num (int): 描述整数
|
||||
text (str): 文本类型
|
||||
is_a (bool): 布尔类型
|
||||
|
||||
Returns:
|
||||
str: 消息
|
||||
"""
|
||||
return "-"
|
||||
|
||||
|
||||
class TestPlugin:
|
||||
def test_get_function_info(self):
|
||||
from nonebot_plugin_marshoai.plugin import get_function_info
|
||||
|
||||
func_info = get_function_info(example_function)
|
||||
print(func_info)
|
Loading…
x
Reference in New Issue
Block a user