From 7497dcb8524253ab8c6ba4d0287efa0f5ba1bf55 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Wed, 30 Oct 2024 11:40:47 +0000 Subject: [PATCH] catch comment source code exception --- crazy_functions/SourceCode_Comment.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crazy_functions/SourceCode_Comment.py b/crazy_functions/SourceCode_Comment.py index 20390800a5..c45da83b4f 100644 --- a/crazy_functions/SourceCode_Comment.py +++ b/crazy_functions/SourceCode_Comment.py @@ -7,6 +7,7 @@ from crazy_functions.agent_fns.python_comment_agent import PythonCodeComment from crazy_functions.diagram_fns.file_tree import FileNode from shared_utils.advanced_markdown_format import markdown_convertion_for_file +from loguru import logger def 注释源代码(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt): @@ -92,7 +93,10 @@ def _task_multi_threading(i_say, gpt_say, fp, file_tree_struct): preview_html_list = [] for done, fp in zip(worker_done, file_manifest): if not done: continue - preview_html_list.append(file_tree_struct.manifest[fp].compare_html) + if hasattr(file_tree_struct.manifest[fp], 'compare_html'): + preview_html_list.append(file_tree_struct.manifest[fp].compare_html) + else: + logger.error(f"文件: {fp} 的注释结果未能成功") file_links = generate_file_link(preview_html_list) yield from update_ui_lastest_msg(