chore(log): 增加 plan_filter 调试日志输出
在 plan_filter 的关键位置增加了详细的日志输出,以便于调试和追踪 plan 的处理流程。 - 在 filter 方法的入口和出口记录 plan 状态。 - 记录构建后的 LLM prompt。 - 将 LLM 原始返回的日志级别调整为 warning,使其更显眼。 - 记录修复和解析后的 JSON 对象。
This commit is contained in:
@@ -42,15 +42,18 @@ class PlanFilter:
|
|||||||
"""
|
"""
|
||||||
执行筛选逻辑,并填充 Plan 对象的 decided_actions 字段。
|
执行筛选逻辑,并填充 Plan 对象的 decided_actions 字段。
|
||||||
"""
|
"""
|
||||||
|
logger.info(f"墨墨在这里加了日志 -> filter 入口 plan: {plan}")
|
||||||
try:
|
try:
|
||||||
prompt, used_message_id_list = await self._build_prompt(plan)
|
prompt, used_message_id_list = await self._build_prompt(plan)
|
||||||
plan.llm_prompt = prompt
|
plan.llm_prompt = prompt
|
||||||
|
logger.info(f"墨墨在这里加了日志 -> LLM prompt: {prompt}")
|
||||||
|
|
||||||
llm_content, _ = await self.planner_llm.generate_response_async(prompt=prompt)
|
llm_content, _ = await self.planner_llm.generate_response_async(prompt=prompt)
|
||||||
|
|
||||||
if llm_content:
|
if llm_content:
|
||||||
logger.debug(f"LLM a原始返回: {llm_content}")
|
logger.warning(f"墨墨在这里加了日志 -> LLM a原始返回: {llm_content}")
|
||||||
parsed_json = orjson.loads(repair_json(llm_content))
|
parsed_json = orjson.loads(repair_json(llm_content))
|
||||||
|
logger.info(f"墨墨在这里加了日志 -> 解析后的 JSON: {parsed_json}")
|
||||||
|
|
||||||
if isinstance(parsed_json, dict):
|
if isinstance(parsed_json, dict):
|
||||||
parsed_json = [parsed_json]
|
parsed_json = [parsed_json]
|
||||||
@@ -91,7 +94,8 @@ class PlanFilter:
|
|||||||
plan.decided_actions = [
|
plan.decided_actions = [
|
||||||
ActionPlannerInfo(action_type="no_action", reasoning=f"筛选时出错: {e}")
|
ActionPlannerInfo(action_type="no_action", reasoning=f"筛选时出错: {e}")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
logger.info(f"墨墨在这里加了日志 -> filter 出口 decided_actions: {plan.decided_actions}")
|
||||||
return plan
|
return plan
|
||||||
|
|
||||||
async def _build_prompt(self, plan: Plan) -> tuple[str, list]:
|
async def _build_prompt(self, plan: Plan) -> tuple[str, list]:
|
||||||
|
|||||||
Reference in New Issue
Block a user