更新API密钥管理,优化意图识别和Excel数据验证功能,增强日志记录,改进错误处理机制,支持文档检索功能,提升代码可读性和灵活性。
This commit is contained in:
@@ -81,21 +81,21 @@ class ExcelDataValidator:
|
||||
"""
|
||||
file_path = file_path or self.input_file
|
||||
if not file_path:
|
||||
logging.error("未指定输入文件路径")
|
||||
logging.error("未指定输入文件路径", exc_info=True)
|
||||
return None
|
||||
|
||||
try:
|
||||
df = pd.read_excel(file_path)
|
||||
required_columns = ["问题", "问题分类", "问题改写", "槽点信息", "检索的内容"]
|
||||
required_columns = ["问题", "问题分类", "问题改写", "槽点信息"]
|
||||
for col in required_columns:
|
||||
if col not in df.columns:
|
||||
logging.error(f"缺少必要的列: {col}")
|
||||
logging.error(f"缺少必要的列: {col}", exc_info=True)
|
||||
return None
|
||||
logging.info(f"成功从{file_path}读取了{len(df)}条数据")
|
||||
self.df = df
|
||||
return df
|
||||
except Exception as e:
|
||||
logging.error(f"读取Excel文件时出错: {e}")
|
||||
logging.error(f"读取Excel文件时出错: {e}", exc_info=True)
|
||||
return None
|
||||
|
||||
def validate_classification(self, llm:OpenAiLLM , query:str, vertical_class:str, sub_class:str):
|
||||
@@ -413,10 +413,7 @@ class ExcelDataValidator:
|
||||
return index, True, "", "", confidence_score
|
||||
except Exception as e:
|
||||
error_msg = f"处理行 {index} 时发生错误: {str(e)}"
|
||||
logging.error(error_msg)
|
||||
if self.debug:
|
||||
import traceback
|
||||
logging.error(traceback.format_exc())
|
||||
logging.error(error_msg, exc_info=True)
|
||||
return index, False, "处理错误", error_msg, 0.0
|
||||
|
||||
def process_batch(self, llm, batch_data):
|
||||
|
||||
Reference in New Issue
Block a user