diff --git a/.cursor/rules/riper-5.mdc b/.cursor/rules/riper-5.mdc index 64f2391..f45266d 100644 --- a/.cursor/rules/riper-5.mdc +++ b/.cursor/rules/riper-5.mdc @@ -73,11 +73,4 @@ n. [Final action] 您无权在声明模式之外做出独立决定 不遵守此协议将给我的代码库带来灾难性的后果 模式转换信号 -仅当我明确发出信号时才转换模式: - -“进入研究模式” -“进入创新模式” -“进入计划模式” -“进入执行模式” -“进入审核模式” -如果没有这些确切的信号,请保持当前模式。 \ No newline at end of file +按照顺序依次执行研究模式->计划模式->执行模式->审核模式 \ No newline at end of file diff --git a/rag2_0/demo/deduplicate_nouns_json.py b/rag2_0/demo/deduplicate_nouns_json.py old mode 100644 new mode 100755 diff --git a/rag2_0/demo/extract_wikijs_nouns.py b/rag2_0/demo/extract_wikijs_nouns.py old mode 100644 new mode 100755 diff --git a/rag2_0/demo/heli_db_to_excel.py b/rag2_0/demo/heli_db_to_excel.py old mode 100644 new mode 100755 diff --git a/rag2_0/demo/intent_recognition_example.py b/rag2_0/demo/intent_recognition_example.py old mode 100644 new mode 100755 index 8ccc587..f553c29 --- a/rag2_0/demo/intent_recognition_example.py +++ b/rag2_0/demo/intent_recognition_example.py @@ -176,8 +176,7 @@ def save_results_to_excel(results, output_file, is_final=False): logging.info(f"已保存{len(valid_results)}条结果至: {temp_output_file}") # 示例查询 -examples_query = """那储能软件如何操作""" -examples_query = """博微软件如何新建工程啊""" +examples_query = """.BDD3是哪款软件编制的""" conversation_context="" chat_history=[ { diff --git a/rag2_0/demo/judge_query_full.py b/rag2_0/demo/judge_query_full.py old mode 100644 new mode 100755 diff --git a/rag2_0/demo/merge_nouns_with_llm.py b/rag2_0/demo/merge_nouns_with_llm.py old mode 100644 new mode 100755 diff --git a/rag2_0/demo/validate_excel_data_batch.py b/rag2_0/demo/validate_excel_data_batch.py old mode 100644 new mode 100755 diff --git a/rag2_0/demo/vectorize_save_noun.py b/rag2_0/demo/vectorize_save_noun.py old mode 100644 new mode 100755 diff --git a/rag2_0/dify/chat_dify_by_workorder.py b/rag2_0/dify/chat_dify_by_workorder.py old mode 100644 new mode 100755 diff --git a/rag2_0/dify/dify_client/__init__.py b/rag2_0/dify/dify_client/__init__.py old mode 100644 new mode 100755 diff --git a/rag2_0/dify/dify_client/client.py b/rag2_0/dify/dify_client/client.py old mode 100644 new mode 100755 diff --git a/rag2_0/dify/dify_tool.py b/rag2_0/dify/dify_tool.py old mode 100644 new mode 100755 diff --git a/rag2_0/dify/intent_recognition_api.py b/rag2_0/dify/intent_recognition_api.py old mode 100644 new mode 100755 diff --git a/rag2_0/dify/test_workorder.py b/rag2_0/dify/test_workorder.py old mode 100644 new mode 100755 diff --git a/rag2_0/intent_recognition/DataModels.py b/rag2_0/intent_recognition/DataModels.py old mode 100644 new mode 100755 diff --git a/rag2_0/intent_recognition/IntentRecognition.py b/rag2_0/intent_recognition/IntentRecognition.py old mode 100644 new mode 100755 index 03329bf..a74e9bc --- a/rag2_0/intent_recognition/IntentRecognition.py +++ b/rag2_0/intent_recognition/IntentRecognition.py @@ -110,6 +110,7 @@ class IntentRecognizer: Returns: 分类结果 """ + classification_start_time = time.time() classification_parser = PydanticOutputParser(pydantic_object=Classification) formatted_prompt = classification_prompt.format(user_input=query, classification_info=classification_info, @@ -119,7 +120,9 @@ class IntentRecognizer: # 调用LLM response = self._llm.invoke(formatted_prompt, False) - + classification_end_time = time.time() + classification_time = classification_end_time - classification_start_time + logging.info(f"意图分类耗时统计 - 总耗时: {classification_time:.2f}秒") # 解析输出 try: # 尝试直接解析JSON响应 @@ -442,9 +445,12 @@ class IntentRecognizer: slot_model = self._get_slot_model(classification) if not slot_model: raise RuntimeError("未找到匹配的槽位模型") - + fill_slots_start_time = time.time() # 使用LLM进行槽位填充 filled_slots = self._fill_slots_with_llm(query, classification, slot_model, conversation_context, chat_history, previous_slots) + fill_slots_end_time = time.time() + fill_slots_time = fill_slots_end_time - fill_slots_start_time + logging.info(f"槽位填充耗时统计 - 总耗时: {fill_slots_time:.2f}秒") # 检查必填槽位是否都已填充 is_complete, missing_slots = filled_slots.check_required_slots() @@ -594,18 +600,8 @@ class IntentRecognizer: if expected_slot_model is None: # 添加容错处理,应对LLM返回错误分类信息,一级分类跟二级分类错乱 # 重新分类 - classify_start_time = time.time() classification = self._classify_intent(user_input, conversation_context, chat_history, previous_slots) - classify_end_time = time.time() - classify_time = classify_end_time - classify_start_time - # logging.info(f"重新分类耗时: {classify_time:.2f}秒") - - fill_start_time = time.time() fill_slots = self._fill_slots(user_input, classification, conversation_context, chat_history, previous_slots) - fill_end_time = time.time() - fill_time = fill_end_time - fill_start_time - all_time=fill_end_time-llm_start_time - logging.info(f"总耗时:{all_time:.2f}秒,首次槽位+分类:{llm_time:.2f}秒, 重新分类耗时: {classify_time:.2f}秒, 重新槽位填充耗时: {fill_time:.2f}秒") result = { "classification": classification.model_dump(), @@ -615,13 +611,7 @@ class IntentRecognizer: return result elif expected_slot_model.__name__ != type(slot_filling).__name__: # 添加容错处理,应对LLM槽位与分类不匹配。重新填充槽位 - fill_start_time = time.time() - slot_filling = self._fill_slots(user_input, classification) - fill_end_time = time.time() - fill_time = fill_end_time - fill_start_time - all_time=fill_end_time-llm_start_time - logging.info(f"总耗时:{all_time:.2f}秒,首次槽位+分类:{llm_time:.2f}秒, 重新槽位填充耗时: {fill_time:.2f}秒") - + slot_filling = self._fill_slots(user_input, classification, conversation_context, chat_history, previous_slots) result = { "classification": classification.model_dump(), "slot_filling": slot_filling diff --git a/rag2_0/intent_recognition/Multi_PromptTemplates.py b/rag2_0/intent_recognition/Multi_PromptTemplates.py old mode 100644 new mode 100755 diff --git a/rag2_0/intent_recognition/ProfessionalNounVector.py b/rag2_0/intent_recognition/ProfessionalNounVector.py old mode 100644 new mode 100755 diff --git a/rag2_0/intent_recognition/PromptTemplates.py b/rag2_0/intent_recognition/PromptTemplates.py old mode 100644 new mode 100755 diff --git a/rag2_0/intent_recognition/__init__.py b/rag2_0/intent_recognition/__init__.py old mode 100644 new mode 100755 diff --git a/rag2_0/tool/APIKeyManager.py b/rag2_0/tool/APIKeyManager.py old mode 100644 new mode 100755 diff --git a/rag2_0/tool/ModelTool.py b/rag2_0/tool/ModelTool.py old mode 100644 new mode 100755 diff --git a/rag2_0/tool/WikijsTool.py b/rag2_0/tool/WikijsTool.py old mode 100644 new mode 100755 diff --git a/rag2_0/tool/__init__.py b/rag2_0/tool/__init__.py old mode 100644 new mode 100755 diff --git a/rag2_0/tool/html_to_md/__init__.py b/rag2_0/tool/html_to_md/__init__.py old mode 100644 new mode 100755 diff --git a/rag2_0/tool/html_to_md/custom_markdownify.py b/rag2_0/tool/html_to_md/custom_markdownify.py old mode 100644 new mode 100755 diff --git a/rag2_0/tool/html_to_md/picture_process.py b/rag2_0/tool/html_to_md/picture_process.py old mode 100644 new mode 100755 diff --git a/rag2_0/tool/wikiconfig.json b/rag2_0/tool/wikiconfig.json old mode 100644 new mode 100755