更新API密钥管理,优化意图识别和Excel数据验证功能,增强日志记录,改进错误处理机制,支持文档检索功能,提升代码可读性和灵活性。

This commit is contained in:
2025-06-24 17:12:09 +08:00
parent 4386cfac41
commit 7142c7c43e
8 changed files with 352 additions and 324 deletions
+4 -5
View File
@@ -135,11 +135,10 @@ class WikijsNounsExtractor:
parsed_output = self.terms_list_parser.parse(response.content)
return parsed_output.terms
except Exception as e:
logging.error(f"解析LLM响应时出错: {str(e)}")
logging.error(f"原始响应: {response.content}")
logging.error(f"解析LLM响应时出错: {str(e)}", exc_info=True)
return []
except Exception as e:
logging.error(f"提取专业名词时出错: {str(e)}")
logging.error(f"提取专业名词时出错: {str(e)}", exc_info=True)
return []
def _process_document(self, doc, path_terms):
@@ -182,7 +181,7 @@ class WikijsNounsExtractor:
return path_prefix
except Exception as e:
logging.error(f"处理文档 {doc['path']} 时出错: {str(e)}")
logging.error(f"处理文档 {doc['path']} 时出错: {str(e)}", exc_info=True)
return None
def process_all_documents(self, output_dir: str = "extracted_nouns", max_concurrency: int = 5):
@@ -237,7 +236,7 @@ class WikijsNounsExtractor:
if i % 10 == 0:
logging.info(f"已完成 {i+1}/{len(futures)} 个文档的处理")
except Exception as e:
logging.error(f"处理文档时出错: {str(e)}")
logging.error(f"处理文档时出错: {str(e)}", exc_info=True)
# 保存最终结果
for prefix, terms in path_terms.items():