mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-10 15:56:03 +00:00
doc: 补全部分注释
This commit is contained in:
@@ -19,6 +19,8 @@ from ..utils import version as version_mgr, proxy as proxy_mgr
|
||||
|
||||
|
||||
class Application:
|
||||
"""运行时应用对象和上下文"""
|
||||
|
||||
im_mgr: im_mgr.PlatformManager = None
|
||||
|
||||
cmd_mgr: cmdmgr.CommandManager = None
|
||||
@@ -77,14 +79,7 @@ class Application:
|
||||
asyncio.create_task(self.ctrl.run())
|
||||
]
|
||||
|
||||
# async def interrupt(tasks):
|
||||
# await asyncio.sleep(1.5)
|
||||
# while await aioconsole.ainput("使用 ctrl+c 或 'exit' 退出程序 > ") != 'exit':
|
||||
# pass
|
||||
# for task in tasks:
|
||||
# task.cancel()
|
||||
|
||||
# await interrupt(tasks)
|
||||
# 挂信号处理
|
||||
|
||||
import signal
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ from __future__ import print_function
|
||||
from . import app
|
||||
from ..audit import identifier
|
||||
from . import stage
|
||||
|
||||
# 引入启动阶段实现以便注册
|
||||
from .stages import load_config, setup_logger, build_app
|
||||
|
||||
|
||||
@@ -20,6 +22,7 @@ async def make_app() -> app.Application:
|
||||
|
||||
ap = app.Application()
|
||||
|
||||
# 执行启动阶段
|
||||
for stage_name in stage_order:
|
||||
stage_cls = stage.preregistered_stages[stage_name]
|
||||
stage_inst = stage_cls()
|
||||
|
||||
@@ -16,6 +16,7 @@ from ..platform import adapter as msadapter
|
||||
|
||||
|
||||
class LauncherTypes(enum.Enum):
|
||||
"""一个请求的发起者类型"""
|
||||
|
||||
PERSON = 'person'
|
||||
"""私聊"""
|
||||
@@ -77,7 +78,7 @@ class Query(pydantic.BaseModel):
|
||||
|
||||
|
||||
class Conversation(pydantic.BaseModel):
|
||||
"""对话"""
|
||||
"""对话,包含于 Session 中,一个 Session 可以有多个历史 Conversation,但只有一个当前使用的 Conversation"""
|
||||
|
||||
prompt: sysprompt_entities.Prompt
|
||||
|
||||
@@ -93,7 +94,7 @@ class Conversation(pydantic.BaseModel):
|
||||
|
||||
|
||||
class Session(pydantic.BaseModel):
|
||||
"""会话"""
|
||||
"""会话,一个 Session 对应一个 {launcher_type}_{launcher_id}"""
|
||||
launcher_type: LauncherTypes
|
||||
|
||||
launcher_id: int
|
||||
@@ -111,6 +112,7 @@ class Session(pydantic.BaseModel):
|
||||
update_time: typing.Optional[datetime.datetime] = pydantic.Field(default_factory=datetime.datetime.now)
|
||||
|
||||
semaphore: typing.Optional[asyncio.Semaphore] = None
|
||||
"""当前会话的信号量,用于限制并发"""
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
@@ -7,6 +7,7 @@ from . import app
|
||||
|
||||
|
||||
preregistered_stages: dict[str, typing.Type[BootingStage]] = {}
|
||||
"""预注册的请求处理阶段。在初始化时,所有请求处理阶段类会被注册到此字典中。"""
|
||||
|
||||
def stage_class(
|
||||
name: str
|
||||
|
||||
@@ -22,7 +22,7 @@ class BuildAppStage(stage.BootingStage):
|
||||
"""
|
||||
|
||||
async def run(self, ap: app.Application):
|
||||
"""启动
|
||||
"""构建app对象的各个组件对象并初始化
|
||||
"""
|
||||
|
||||
proxy_mgr = proxy.ProxyManager(ap)
|
||||
|
||||
Reference in New Issue
Block a user