更新API密钥管理,优化意图识别和Excel数据验证功能,增强日志记录,改进错误处理机制,支持文档检索功能,提升代码可读性和灵活性。
This commit is contained in:
@@ -635,7 +635,7 @@ class IntentRecognizer:
|
||||
return parsed_output
|
||||
except Exception as e:
|
||||
# 如果解析失败,返回原始查询作为后退提示
|
||||
logging.error(f"后退提示生成失败: {e}")
|
||||
logging.error(f"后退提示生成失败: {e}", exc_info=True)
|
||||
return StepBackPrompt(original_query=query, step_back_query=query)
|
||||
|
||||
def _generate_follow_up_questions(self, query: str, chat_history: List[Dict[str, str]] = None, conversation_context: str = "") -> FollowUpQuestions:
|
||||
@@ -672,7 +672,7 @@ class IntentRecognizer:
|
||||
return parsed_output
|
||||
except Exception as e:
|
||||
# 如果解析失败,返回原始查询作为后续问题
|
||||
logging.error(f"后续问题生成失败: {e}")
|
||||
logging.error(f"后续问题生成失败: {e}", exc_info=True)
|
||||
return FollowUpQuestions(original_query=query, follow_up_query=query)
|
||||
|
||||
def _generate_hypothetical_document(self, query: str, chat_history: List[Dict[str, str]] = None, conversation_context: str = "") -> HypotheticalDocument:
|
||||
@@ -709,7 +709,7 @@ class IntentRecognizer:
|
||||
return parsed_output
|
||||
except Exception as e:
|
||||
# 如果解析失败,返回空的假设性回答
|
||||
logging.error(f"假设性文档生成失败: {e}")
|
||||
logging.error(f"假设性文档生成失败: {e}", exc_info=True)
|
||||
return HypotheticalDocument(original_query=query, hypothetical_answer="")
|
||||
|
||||
def _generate_multi_questions(self, query: str, chat_history: List[Dict[str, str]] = None, conversation_context: str = "") -> MultiQuestions:
|
||||
@@ -746,7 +746,7 @@ class IntentRecognizer:
|
||||
return parsed_output
|
||||
except Exception as e:
|
||||
# 如果解析失败,返回原始查询作为唯一子问题
|
||||
logging.error(f"多角度问题生成失败: {e},LLM返回内容:{response.content}")
|
||||
logging.error(f"多角度问题生成失败: {e}",exc_info=True)
|
||||
return MultiQuestions(original_query=query, sub_questions=[query])
|
||||
|
||||
def _run_in_thread(self, func, args=(), kwargs={}):
|
||||
@@ -768,7 +768,7 @@ class IntentRecognizer:
|
||||
result = func(*args, **kwargs)
|
||||
result_container.append(result)
|
||||
except Exception as e:
|
||||
logging.error(f"线程执行函数 {func.__name__} 时出错: {e}")
|
||||
logging.error(f"线程执行函数 {func.__name__} 时出错: {e}", exc_info=True)
|
||||
result_container.append(None)
|
||||
|
||||
thread = threading.Thread(target=thread_target)
|
||||
@@ -866,5 +866,4 @@ class IntentRecognizer:
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"process_intent_and_slot error:{e}")
|
||||
raise RuntimeError(f"process_intent_and_slot error:{e}") from e
|
||||
Reference in New Issue
Block a user