config.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. """
  2. 运行配置 — 自动化投放 Agent 系统
  3. """
  4. from pathlib import Path
  5. from agent.core.runner import RunConfig, KnowledgeConfig
  6. # ===== 工具白名单 =====
  7. # 只暴露业务工具,避免 LLM 误调 IM/知识库/浏览器等非业务工具
  8. ANALYSIS_TOOLS = [
  9. # 数据查询
  10. "data_query",
  11. "data_aggregate",
  12. "get_ad_current_status",
  13. # 广告 API(只读)
  14. "account_get_info",
  15. "ad_get_list",
  16. "ad_get_report",
  17. "creative_get_report",
  18. "asset_get_list",
  19. "audience_get_list",
  20. # 人群定向
  21. "audience_build_targeting",
  22. "audience_recommend_targeting",
  23. # 监控
  24. "monitor_check_metrics",
  25. ]
  26. EXECUTION_TOOLS = ANALYSIS_TOOLS + [
  27. # 执行类工具(仅执行 Agent 使用)
  28. "bid_adjustment_execute",
  29. "ad_create",
  30. "ad_update",
  31. "ad_batch_update_status",
  32. "creative_create",
  33. "creative_update",
  34. "monitor_circuit_break",
  35. ]
  36. # ===== Main Agent 配置(统一入口) =====
  37. MAIN_CONFIG = RunConfig(
  38. model="qwen/qwen3.5-plus-02-15",
  39. temperature=0.3,
  40. max_iterations=50,
  41. name="投放决策中枢",
  42. tools=ANALYSIS_TOOLS + ["agent"], # 加入 agent 工具用于调度子 Agent
  43. skills=["planning", "ad_domain"], # Main Agent 只需要通用知识
  44. extra_llm_params={"extra_body": {"enable_thinking": True}},
  45. knowledge=KnowledgeConfig(
  46. enable_extraction=False,
  47. enable_completion_extraction=False,
  48. enable_injection=False,
  49. owner="ad_placement_team",
  50. ),
  51. )
  52. # ===== Budget Agent 配置 =====
  53. BUDGET_CONFIG = RunConfig(
  54. model="qwen/qwen3.5-plus-02-15",
  55. temperature=0.3,
  56. max_iterations=30,
  57. name="预算出价Agent",
  58. tools=[
  59. # 配置层
  60. "load_strategy_config", "update_strategy_config", "get_config_history",
  61. # 数据获取
  62. "get_ad_performance", "get_account_summary", "data_query",
  63. # 计算
  64. "compute_budget_thresholds", "classify_ads", "compute_bid_adjustment",
  65. # 只读 API
  66. "ad_get_list", "ad_get_report",
  67. ],
  68. skills=["ad_domain", "budget_strategy"], # 只注入预算相关知识
  69. extra_llm_params={"extra_body": {"enable_thinking": True}},
  70. knowledge=KnowledgeConfig(
  71. enable_extraction=False,
  72. enable_completion_extraction=False,
  73. enable_injection=False,
  74. owner="ad_placement_team",
  75. ),
  76. )
  77. # ===== 执行 Agent 配置 =====
  78. EXECUTE_CONFIG = RunConfig(
  79. model="qwen/qwen3.5-plus-02-15",
  80. temperature=0.1, # 执行Agent更低温度,减少随机性
  81. max_iterations=30,
  82. name="投放执行系统",
  83. tools=EXECUTION_TOOLS,
  84. skills=["planning", "ad_domain", "budget_strategy", "monitor_rules"],
  85. extra_llm_params={"extra_body": {"enable_thinking": True}},
  86. knowledge=KnowledgeConfig(
  87. enable_extraction=False,
  88. enable_completion_extraction=False,
  89. enable_injection=False,
  90. owner="ad_placement_team",
  91. ),
  92. )
  93. # 向后兼容:默认使用 Main Agent
  94. RUN_CONFIG = MAIN_CONFIG
  95. # 基础设施配置
  96. SKILLS_DIR = str(Path(__file__).parent / "skills")
  97. TRACE_STORE_PATH = ".trace"
  98. LOG_LEVEL = "INFO"
  99. LOG_FILE = None