修改了结果保存逻辑,原始状态下推文保存位置错误
This commit is contained in:
parent
096c78c513
commit
be8639406c
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/result/
|
||||
*.zip
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user