feat: switch Query to langbot-plugin definition

This commit is contained in:
Junyan Qin
2025-06-15 22:04:31 +08:00
parent 0c2560cafb
commit 6b782f8761
88 changed files with 248 additions and 348 deletions
+9 -6
View File
@@ -5,7 +5,7 @@ import traceback
import sqlalchemy
from ..core import app, entities
from ..core import app
from . import entities as pipeline_entities
from ..entity.persistence import pipeline as persistence_pipeline
from . import stage
@@ -13,6 +13,9 @@ from ..platform.types import message as platform_message, events as platform_eve
from ..plugin import events
from ..utils import importutil
import langbot_plugin.api.entities.builtin.provider.session as provider_session
import langbot_plugin.api.entities.builtin.pipeline.query as pipeline_query
from . import (
resprule,
bansess,
@@ -75,11 +78,11 @@ class RuntimePipeline:
self.pipeline_entity = pipeline_entity
self.stage_containers = stage_containers
async def run(self, query: entities.Query):
async def run(self, query: pipeline_query.Query):
query.pipeline_config = self.pipeline_entity.config
await self.process_query(query)
async def _check_output(self, query: entities.Query, result: pipeline_entities.StageProcessResult):
async def _check_output(self, query: pipeline_query.Query, result: pipeline_entities.StageProcessResult):
"""检查输出"""
if result.user_notice:
# 处理str类型
@@ -109,7 +112,7 @@ class RuntimePipeline:
async def _execute_from_stage(
self,
stage_index: int,
query: entities.Query,
query: pipeline_query.Query,
):
"""从指定阶段开始执行,实现了责任链模式和基于生成器的阶段分叉功能。
@@ -169,13 +172,13 @@ class RuntimePipeline:
i += 1
async def process_query(self, query: entities.Query):
async def process_query(self, query: pipeline_query.Query):
"""处理请求"""
try:
# ======== 触发 MessageReceived 事件 ========
event_type = (
events.PersonMessageReceived
if query.launcher_type == entities.LauncherTypes.PERSON
if query.launcher_type == provider_session.LauncherTypes.PERSON
else events.GroupMessageReceived
)