继续处理中断的任务
(recipe_dir: str, output_dir: str)
| 122 | print(f"❌ 合并失败: {str(e)}") |
| 123 | |
| 124 | def continue_processing(recipe_dir: str, output_dir: str): |
| 125 | """继续处理中断的任务""" |
| 126 | config = load_config() |
| 127 | api_key = config["openai"].get("api_key") |
| 128 | |
| 129 | if not api_key: |
| 130 | print("❌ 未找到API密钥配置") |
| 131 | return |
| 132 | |
| 133 | try: |
| 134 | ai_agent = LLMRecipeAgent(api_key) |
| 135 | batch_size = config.get("processing", {}).get("batch_size", 20) |
| 136 | builder = RecipeKnowledgeGraphBuilder(ai_agent, output_dir, batch_size) |
| 137 | |
| 138 | print("继续处理中断的任务...") |
| 139 | processed, failed = builder.batch_process_recipes(recipe_dir, resume=True) |
| 140 | |
| 141 | print(f"处理完成: 总数 {processed}, 失败 {failed}") |
| 142 | |
| 143 | # 自动合并数据 |
| 144 | print("自动合并批次数据...") |
| 145 | merge_batches(output_dir) |
| 146 | |
| 147 | except Exception as e: |
| 148 | print(f"❌ 处理失败: {str(e)}") |
| 149 | |
| 150 | def show_batch_details(output_dir: str, batch_num: int = None): |
| 151 | """显示批次详细信息""" |
no test coverage detected