mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-02 15:47:16 +00:00
chore: 完善plugin对外对象的注释
This commit is contained in:
+46
-1
@@ -13,19 +13,64 @@ def register(
|
|||||||
name: str,
|
name: str,
|
||||||
description: str,
|
description: str,
|
||||||
version: str,
|
version: str,
|
||||||
author
|
author: str
|
||||||
) -> typing.Callable[[typing.Type[BasePlugin]], typing.Type[BasePlugin]]:
|
) -> typing.Callable[[typing.Type[BasePlugin]], typing.Type[BasePlugin]]:
|
||||||
|
"""注册插件类
|
||||||
|
|
||||||
|
使用示例:
|
||||||
|
|
||||||
|
@register(
|
||||||
|
name="插件名称",
|
||||||
|
description="插件描述",
|
||||||
|
version="插件版本",
|
||||||
|
author="插件作者"
|
||||||
|
)
|
||||||
|
class MyPlugin(BasePlugin):
|
||||||
|
pass
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handler(
|
def handler(
|
||||||
event: typing.Type[events.BaseEventModel]
|
event: typing.Type[events.BaseEventModel]
|
||||||
) -> typing.Callable[[typing.Callable], typing.Callable]:
|
) -> typing.Callable[[typing.Callable], typing.Callable]:
|
||||||
|
"""注册事件监听器
|
||||||
|
|
||||||
|
使用示例:
|
||||||
|
|
||||||
|
class MyPlugin(BasePlugin):
|
||||||
|
|
||||||
|
@handler(NormalMessageResponded)
|
||||||
|
async def on_normal_message_responded(self, ctx: EventContext):
|
||||||
|
pass
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def llm_func(
|
def llm_func(
|
||||||
name: str=None,
|
name: str=None,
|
||||||
) -> typing.Callable:
|
) -> typing.Callable:
|
||||||
|
"""注册内容函数
|
||||||
|
|
||||||
|
使用示例:
|
||||||
|
|
||||||
|
class MyPlugin(BasePlugin):
|
||||||
|
|
||||||
|
@llm_func("access_the_web_page")
|
||||||
|
async def _(self, query, url: str, brief_len: int):
|
||||||
|
\"""Call this function to search about the question before you answer any questions.
|
||||||
|
- Do not search through google.com at any time.
|
||||||
|
- If you need to search somthing, visit https://www.sogou.com/web?query=<something>.
|
||||||
|
- If user ask you to open a url (start with http:// or https://), visit it directly.
|
||||||
|
- Summary the plain content result by yourself, DO NOT directly output anything in the result you got.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
url(str): url to visit
|
||||||
|
brief_len(int): max length of the plain text content, recommend 1024-4096, prefer 4096
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: plain text content of the web page or error message(starts with 'error:')
|
||||||
|
\"""
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class BaseEventModel(pydantic.BaseModel):
|
|||||||
"""事件模型基类"""
|
"""事件模型基类"""
|
||||||
|
|
||||||
query: typing.Union[core_entities.Query, None]
|
query: typing.Union[core_entities.Query, None]
|
||||||
"""此次请求的query对象,可能为None"""
|
"""此次请求的query对象,非请求过程的事件时为None"""
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
arbitrary_types_allowed = True
|
arbitrary_types_allowed = True
|
||||||
|
|||||||
Reference in New Issue
Block a user