__init__.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. """
  2. find_agent 工具包
  3. 在此注册本 Agent 专属的工具。
  4. """
  5. from __future__ import annotations
  6. import sys
  7. from collections.abc import Callable
  8. from typing import Any
  9. from agents.find_agent.support import (
  10. portrait as _portrait,
  11. qwen_video_analysis as _qwen_video_analysis,
  12. search_persistence as _search_persistence,
  13. video_discovery as _video_discovery,
  14. )
  15. from agents.find_agent.tools.batch_fetch_portraits import batch_fetch_portraits
  16. from agents.find_agent.tools.batch_search_and_record import batch_search_and_record
  17. from agents.find_agent.tools.batch_update_video_discovery_candidates import (
  18. batch_update_video_discovery_candidates,
  19. )
  20. from agents.find_agent.tools.douyin_detail import douyin_detail
  21. from agents.find_agent.tools.douyin_search import douyin_search
  22. from agents.find_agent.tools.douyin_search_tikhub import douyin_search_tikhub
  23. from agents.find_agent.tools.douyin_user_videos import douyin_user_videos
  24. from agents.find_agent.tools.get_account_fans_portrait import (
  25. get_account_fans_portrait,
  26. )
  27. from agents.find_agent.tools.get_content_fans_portrait import (
  28. get_content_fans_portrait,
  29. )
  30. from agents.find_agent.tools.normalize_age_portraits import normalize_age_portraits
  31. from agents.find_agent.tools.query_video_discovery_state import (
  32. query_video_discovery_state,
  33. )
  34. from agents.find_agent.tools.update_video_discovery_run_status import (
  35. update_video_discovery_run_status,
  36. )
  37. from supply_agent.tools.registry import ToolRegistry
  38. # 旧调用方的模块路径兼容。实现均已迁出 tools,且不会注册为 Agent 工具。
  39. _LEGACY_MODULE_ALIASES = {
  40. "hotspot_profile": _portrait,
  41. "qwen_video_analyze": _qwen_video_analysis,
  42. "search_persistence": _search_persistence,
  43. "video_discovery_store": _video_discovery,
  44. }
  45. for _legacy_name, _support_module in _LEGACY_MODULE_ALIASES.items():
  46. sys.modules.setdefault(
  47. f"{__name__}.{_legacy_name}",
  48. _support_module,
  49. )
  50. ALL_TOOLS: list[Callable[..., Any]] = [
  51. batch_search_and_record,
  52. douyin_search,
  53. douyin_search_tikhub,
  54. douyin_user_videos,
  55. douyin_detail,
  56. get_content_fans_portrait,
  57. get_account_fans_portrait,
  58. batch_fetch_portraits,
  59. normalize_age_portraits,
  60. batch_update_video_discovery_candidates,
  61. update_video_discovery_run_status,
  62. query_video_discovery_state,
  63. ]
  64. __all__ = [
  65. "ALL_TOOLS",
  66. "batch_search_and_record",
  67. "douyin_search",
  68. "douyin_search_tikhub",
  69. "douyin_user_videos",
  70. "douyin_detail",
  71. "get_content_fans_portrait",
  72. "get_account_fans_portrait",
  73. "batch_fetch_portraits",
  74. "normalize_age_portraits",
  75. "batch_update_video_discovery_candidates",
  76. "update_video_discovery_run_status",
  77. "query_video_discovery_state",
  78. "register_all_tools",
  79. ]
  80. def register_all_tools(registry: ToolRegistry) -> ToolRegistry:
  81. """将 find_agent 包内的所有工具注册到 ToolRegistry。"""
  82. return registry.from_decorated(*ALL_TOOLS)