dump_tools_for_merge.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import json
  2. import logging
  3. from tool_agent.tool.tool_store import PostgreSQLToolStore
  4. logging.basicConfig(level=logging.INFO)
  5. def dump_tools():
  6. store = PostgreSQLToolStore()
  7. tools = store.list_all(limit=1000)
  8. connected = []
  9. unconnected = []
  10. for t in tools:
  11. if t.get("status") == "已接入":
  12. connected.append({
  13. "id": t.get("id"),
  14. "name": t.get("name"),
  15. "introduction": t.get("introduction"),
  16. "capability_ids": t.get("capability_ids", [])
  17. })
  18. else:
  19. unconnected.append({
  20. "id": t.get("id"),
  21. "name": t.get("name"),
  22. "introduction": t.get("introduction"),
  23. "capability_ids": t.get("capability_ids", [])
  24. })
  25. with open("tool_dump.json", "w", encoding="utf-8") as f:
  26. json.dump({"connected": connected, "unconnected": unconnected}, f, ensure_ascii=False, indent=2)
  27. print(f"Dumped {len(connected)} connected tools and {len(unconnected)} unconnected tools.")
  28. if __name__ == "__main__":
  29. dump_tools()