优化测试脚本stage分别输出
This commit is contained in:
Binary file not shown.
@@ -39,6 +39,52 @@ def _select_stage():
|
||||
print("❌ 请输入 1-6 之间的数字")
|
||||
|
||||
|
||||
def _summarize_system_prompt_origin(obj: dict, upstream: dict) -> str:
|
||||
"""
|
||||
根据上游 stage1 推断 system_prompt 的拼接顺序,仅展示文件名,不输出全文。
|
||||
"""
|
||||
stage1 = upstream.get("stage1") or {}
|
||||
scene_mode = stage1.get("scene_mode", "scene4")
|
||||
drone_state = stage1.get("drone_state", "on_ground")
|
||||
intent_type = stage1.get("intent_type", "generic_mission")
|
||||
|
||||
if scene_mode == "simple":
|
||||
return "【system_prompt 来源】simple_mode_prompt.txt"
|
||||
|
||||
parts = [
|
||||
"macro_header.txt",
|
||||
"core_nodes.json (裁剪后)",
|
||||
f"template_{'ground' if drone_state == 'on_ground' else 'air'}.txt",
|
||||
"common_rules.txt",
|
||||
]
|
||||
if intent_type == "generic_mission":
|
||||
parts.append("[可选] system_extra_examples.txt")
|
||||
parts.append("任务意图标签 (代码生成)")
|
||||
return "【system_prompt 来源】" + " → ".join(parts)
|
||||
|
||||
|
||||
def _summarize_output_for_display(obj: dict, upstream: dict) -> dict:
|
||||
"""将 output/upstream 中的 system_prompt、final_prompt 替换为简要说明,便于终端查看"""
|
||||
if not isinstance(obj, dict):
|
||||
return obj
|
||||
out = {}
|
||||
for k, v in obj.items():
|
||||
if k == "system_prompt" and isinstance(v, str) and len(v) > 200:
|
||||
out[k] = _summarize_system_prompt_origin(obj, upstream) + f"\n(全文约 {len(v)} 字符,已保存至 response.json)"
|
||||
elif k == "final_prompt" and isinstance(v, str) and len(v) > 200:
|
||||
out[k] = f"【final_prompt】= system_prompt + user_prompt (全文约 {len(v)} 字符,已保存至 response.json)"
|
||||
elif isinstance(v, dict):
|
||||
out[k] = _summarize_output_for_display(v, upstream)
|
||||
elif isinstance(v, list):
|
||||
out[k] = [
|
||||
_summarize_output_for_display(item, upstream) if isinstance(item, dict) else item
|
||||
for item in v
|
||||
]
|
||||
else:
|
||||
out[k] = v
|
||||
return out
|
||||
|
||||
|
||||
def _infer_drone_state_from_prompt(prompt: str) -> str:
|
||||
"""从指令中简单推断 drone_state(批量模式下若未单独指定则用此)"""
|
||||
if "在空中" in prompt or "已起飞" in prompt:
|
||||
@@ -75,8 +121,23 @@ def run_stage_debug_single():
|
||||
print(f"✅ 请求成功 (耗时: {result['latency']:.2f}s)")
|
||||
data = result["data"]
|
||||
output = data.get("output", data)
|
||||
upstream = data.get("upstream") or {}
|
||||
target_stage = data.get("target_stage", 0)
|
||||
if target_stage >= 2 and not upstream:
|
||||
print("\n⚠️ 未获取到上游 Stage 输出。请重启后端服务 (如 start_all.sh) 后重试。")
|
||||
elif upstream:
|
||||
print("\n" + "=" * 60)
|
||||
print("【上游 Stage 输出】")
|
||||
print("=" * 60)
|
||||
for k, v in sorted(upstream.items()):
|
||||
print(f"\n--- {k} ---")
|
||||
summarized = _summarize_output_for_display(v, upstream)
|
||||
print(json.dumps(summarized, ensure_ascii=False, indent=2))
|
||||
print("\n" + "=" * 60)
|
||||
print(json.dumps(output, ensure_ascii=False, indent=2))
|
||||
print(f"【Stage{data.get('target_stage', '?')} 输出】")
|
||||
print("=" * 60)
|
||||
summarized_output = _summarize_output_for_display(output, upstream)
|
||||
print(json.dumps(summarized_output, ensure_ascii=False, indent=2))
|
||||
print("=" * 60)
|
||||
|
||||
# 保存到 validation/temporary
|
||||
|
||||
Reference in New Issue
Block a user