import sys, asyncio, json, os
sys.path.insert(0, 'apps/backend')
from dotenv import load_dotenv
load_dotenv(dotenv_path=os.path.join(os.getcwd(), '.env'))
from app.ai.prompts.app2_finance_prompt import build_prompt


async def main() -> None:
    p = await build_prompt({'site_id': 2790685415443269, 'time_dimension': 'this_month', 'area': 'all'})
    pretty = json.dumps(json.loads(p), ensure_ascii=False, indent=2)
    md = f"""# App2 财务洞察 — 本月/全部区域 (v6 异常日含星期)

- 生成时间：2026-04-22
- Prompt 长度：{len(p)} 字符
- 异常日参数：阈值 40%、上限 10、最少 7 天样本
- 新增：日期带星期中文，AI 可识别周中规律

## 完整 Prompt

```json
{pretty}
```
"""
    out = r'c:/Project/NeoZQYY/export/ai-prompt-samples/app2_this_month_all_v6_anomaly_with_weekday.md'
    with open(out, 'w', encoding='utf-8') as f:
        f.write(md)
    print(f'prompt={len(p)} chars, md saved to {out}')


if __name__ == '__main__':
    asyncio.run(main())
