Skip to content

模块 nonebot_plugin_marshoai.plugin.func_call.params

var P

  • 说明: 参数类型泛型

  • 默认值: TypeVar('P', bound='Parameter')

class ParamTypes

attr STRING = 'string'

attr INTEGER = 'integer'

attr ARRAY = 'array'

attr OBJECT = 'object'

attr BOOLEAN = 'boolean'

attr NUMBER = 'number'

class Parameter(BaseModel)


func data(self) -> dict[str, Any]

源代码在GitHub上查看
python
def data(self) -> dict[str, Any]:
    return {'type': self.type_, 'description': self.description, **{k: v for k, v in self.properties.items() if v is not None}}

attr type_: str = NO_DEFAULT

attr description: str = NO_DEFAULT

attr default: Any = None

attr properties: dict[str, Any] = {}

attr required: bool = False

class String(Parameter)

attr type_: str = ParamTypes.STRING

attr properties: dict[str, Any] = Field(default_factory=dict)

attr enum: list[str] | None = None

class Integer(Parameter)

attr type_: str = ParamTypes.INTEGER

attr properties: dict[str, Any] = Field(default_factory=lambda: {'minimum': 0, 'maximum': 100})

attr minimum: int | None = None

attr maximum: int | None = None

class Array(Parameter)

attr type_: str = ParamTypes.ARRAY

attr properties: dict[str, Any] = Field(default_factory=lambda: {'items': {'type': 'string'}})

attr items: str = Field('string', description='数组元素类型')

class FunctionCall(BaseModel)


func hash self => int

源代码在GitHub上查看
python
def __hash__(self) -> int:
    return hash(self.name)

func data(self) -> dict[str, Any]

说明: 生成函数描述信息

返回: dict[str, Any]: 函数描述信息 字典

源代码在GitHub上查看
python
def data(self) -> dict[str, Any]:
    return {'type': 'function', 'function': {'name': self.name, 'description': self.description, 'parameters': {'type': 'object', 'properties': {k: v.data() for k, v in self.arguments.items()}}, 'required': [k for k, v in self.arguments.items() if v.default is None], **self.kwargs}}

attr name: str = NO_DEFAULT

attr description: str = NO_DEFAULT

attr arguments: dict[str, Parameter] = NO_DEFAULT

attr function: FUNCTION_CALL_FUNC = NO_DEFAULT

attr kwargs: dict[str, Any] = {}

文档完善中,欢迎提出建议或帮助我们完善。