diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..312ba94 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/result/ +*.zip diff --git a/utils/tweet_generator.py b/utils/tweet_generator.py index 35c73d6..41bd9da 100644 --- a/utils/tweet_generator.py +++ b/utils/tweet_generator.py @@ -171,12 +171,24 @@ def generate_single_content(ai_agent, system_prompt, user_prompt, item, output_d print(f"生成完成,tokens: {tokens}, 耗时: {time_cost}s") - # 保存到单独文件 + # --- Correct directory structure --- + # Define the full path to the run-specific directory + run_specific_output_dir = os.path.join(output_dir, run_id) # e.g., result/2025-04-22... + + # Define the directory for this specific article variant *under* the run directory + variant_result_dir = os.path.join(run_specific_output_dir, f"{article_index}_{variant_index}") # e.g., result/2025-04-22.../1_1 + os.makedirs(variant_result_dir, exist_ok=True) # Ensure the variant directory exists + + # Create the tweetContent object (output_dir param might be irrelevant for saving) tweet_content = tweetContent(result, user_prompt, output_dir, run_id, article_index, variant_index) - result_dir = os.path.join(output_dir, f"{article_index}_{variant_index}") - os.makedirs(result_dir, exist_ok=True) - tweet_content.save_content(os.path.join(result_dir, "article.json")) - tweet_content.save_prompt(os.path.join(result_dir, "tweet_prompt.txt")) + + # Save content and prompt to the correct variant directory + content_save_path = os.path.join(variant_result_dir, "article.json") + prompt_save_path = os.path.join(variant_result_dir, "tweet_prompt.txt") + tweet_content.save_content(content_save_path) + tweet_content.save_prompt(prompt_save_path) + print(f" Saved article content to: {content_save_path}") # Add log for confirmation + # --- End directory structure correction --- return tweet_content, result except Exception as e: