45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
示例脚本:仅执行选题生成步骤 (阶段 1)
|
||
"""
|
||
import os
|
||
import sys
|
||
|
||
# 添加项目根目录到Python路径
|
||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||
|
||
# 导入所需模块
|
||
from main import load_config, generate_topics_step
|
||
|
||
if __name__ == "__main__":
|
||
print("==== 阶段 1: 仅生成选题 ====")
|
||
|
||
try:
|
||
# 1. 加载配置
|
||
print("加载配置...")
|
||
# 可以通过命令行参数指定配置文件,这里使用默认值
|
||
config = load_config()
|
||
print("配置加载成功。")
|
||
|
||
# 2. 执行选题生成
|
||
print("\n执行选题生成...")
|
||
run_id, tweet_topic_record = generate_topics_step(config)
|
||
|
||
if run_id and tweet_topic_record:
|
||
output_dir = config.get("output_dir", "./result")
|
||
topics_file = os.path.join(output_dir, run_id, "tweet_topic.json")
|
||
print("\n==== 选题生成成功 ====")
|
||
print(f"Run ID: {run_id}")
|
||
print(f"生成的选题数量: {len(tweet_topic_record.topics_list)}")
|
||
print(f"选题文件已保存到: {topics_file}")
|
||
print("\n请记录下 Run ID,阶段 2 将需要它。")
|
||
else:
|
||
print("\n==== 选题生成失败 ====")
|
||
sys.exit(1)
|
||
|
||
except Exception as e:
|
||
print(f"\n处理过程中出错: {e}")
|
||
import traceback
|
||
traceback.print_exc()
|
||
sys.exit(1) |