check_templates_body.py 895 B

123456789101112131415161718192021222324252627282930
  1. """检查模板数据"""
  2. import requests
  3. API_BASE = "http://localhost:8000/api"
  4. response = requests.get(f"{API_BASE}/templates")
  5. templates = response.json()
  6. print(f"总模板数: {len(templates)}")
  7. print()
  8. # 统计
  9. with_body = 0
  10. without_body = 0
  11. for tpl in templates[:10]:
  12. has_body = bool(tpl.get('template_body'))
  13. if has_body:
  14. with_body += 1
  15. print(f"✅ {tpl['machine_model']}/{tpl['template_type']}")
  16. print(f" body长度: {len(tpl['template_body'])}")
  17. print(f" body前100字符: {tpl['template_body'][:100]}")
  18. else:
  19. without_body += 1
  20. print(f"❌ {tpl['machine_model']}/{tpl['template_type']} - 无template_body")
  21. if tpl.get('reusable_from'):
  22. print(f" 复用来源: {tpl['reusable_from']}")
  23. print()
  24. print(f"\n前10个中: {with_body} 有body, {without_body} 无body")