diff --git a/pkg/core/entities.py b/pkg/core/entities.py index 7f7088c4..6305a0ec 100644 --- a/pkg/core/entities.py +++ b/pkg/core/entities.py @@ -73,6 +73,9 @@ class Query(pydantic.BaseModel): resp_message_chain: typing.Optional[list[mirai.MessageChain]] = None """回复消息链,从resp_messages包装而得""" + # ======= 内部保留 ======= + current_stage: "pkg.pipeline.stagemgr.StageInstContainer" = None + class Config: arbitrary_types_allowed = True diff --git a/pkg/pipeline/controller.py b/pkg/pipeline/controller.py index e63a2a64..677db31d 100644 --- a/pkg/pipeline/controller.py +++ b/pkg/pipeline/controller.py @@ -122,6 +122,8 @@ async def _execute_from_stage( while i < len(self.ap.stage_mgr.stage_containers): stage_container = self.ap.stage_mgr.stage_containers[i] + + query.current_stage = stage_container # 标记到 Query 对象里 result = stage_container.inst.process(query, stage_container.inst_name) @@ -162,7 +164,7 @@ async def process_query(self, query: entities.Query): try: await self._execute_from_stage(0, query) except Exception as e: - self.ap.logger.error(f"处理请求时出错 query_id={query.query_id}: {e}") + self.ap.logger.error(f"处理请求时出错 query_id={query.query_id} stage={query.current_stage.inst_name} : {e}") self.ap.logger.debug(f"Traceback: {traceback.format_exc()}") # traceback.print_exc() finally: