| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #!/usr/bin/env python3
- """
- 完整广告分析流程脚本
- 执行 Step 1-10 的完整决策流程
- """
- import asyncio
- import sys
- from pathlib import Path
- # 添加项目路径
- sys.path.insert(0, str(Path(__file__).parent))
- from agent.tools.models import ToolContext
- from tools.data_query import fetch_creative_data
- from tools.creative_metrics import merge_creative_data
- from tools.roi_calculator import calculate_roi_metrics
- from tools.ad_decision import get_ads_for_review
- async def main():
- """执行完整分析流程"""
-
- # 创建工具上下文
- ctx = ToolContext(
- agent_id="auto_put_ad_mini",
- session_id="manual_run",
- trace_id="manual_trace"
- )
-
- end_date = "20260420"
- days = 7
-
- print("=" * 60)
- print("Step 1: 拉取创意数据")
- print("=" * 60)
- result1 = await fetch_creative_data(ctx, days=days, end_date=end_date)
- print(result1.output)
-
- print("\n" + "=" * 60)
- print("Step 2: 合并创意数据")
- print("=" * 60)
- result2 = await merge_creative_data(ctx, days=days, force=False)
- print(result2.output)
-
- print("\n" + "=" * 60)
- print("Step 3: 计算 ROI 指标")
- print("=" * 60)
- result3 = await calculate_roi_metrics(ctx, end_date=end_date)
- print(result3.output)
-
- print("\n" + "=" * 60)
- print("Step 4: 获取待评估广告")
- print("=" * 60)
- result4 = await get_ads_for_review(ctx, metrics_csv="", end_date=end_date)
- print(result4.output)
-
- print("\n" + "=" * 60)
- print("数据准备完成!")
- print("=" * 60)
- print("\n接下来需要 AI 对待评估广告进行推理决策...")
- if __name__ == "__main__":
- asyncio.run(main())
|