From 7d080a9a9cce20331123f92efe23f5392fb95a94 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Mon, 23 Jun 2025 20:52:20 +0800 Subject: [PATCH] 'commit' --- ...4_ManageMapping.py => T1_ManageMapping.py} | 0 dsRag/{T6_Train.py => T2_ImportTxt.py} | 0 dsRag/{T9_RAG.py => T3_DeepSeekRag.py} | 0 dsRag/{ => Test}/T1_HelloWord.py | 0 dsRag/{ => Test}/T2_Txt2Vec.py | 0 dsRag/{ => Test}/T3_LinkEs.py | 4 +++- dsRag/Test/T4_TestIKSmart.py | 20 ++++++++++++++++++ dsRag/{ => Test}/T5_SentenceSave.py | 4 ++-- dsRag/{T7_Query.py => Test/T6_Query.py} | 2 +- .../T7_CallDeepSeek.py} | 0 dsRag/__pycache__/T2_Txt2Vec.cpython-310.pyc | Bin 650 -> 0 bytes 11 files changed, 26 insertions(+), 4 deletions(-) rename dsRag/{T4_ManageMapping.py => T1_ManageMapping.py} (100%) rename dsRag/{T6_Train.py => T2_ImportTxt.py} (100%) rename dsRag/{T9_RAG.py => T3_DeepSeekRag.py} (100%) rename dsRag/{ => Test}/T1_HelloWord.py (100%) rename dsRag/{ => Test}/T2_Txt2Vec.py (100%) rename dsRag/{ => Test}/T3_LinkEs.py (91%) create mode 100644 dsRag/Test/T4_TestIKSmart.py rename dsRag/{ => Test}/T5_SentenceSave.py (93%) rename dsRag/{T7_Query.py => Test/T6_Query.py} (93%) rename dsRag/{T8_CallDeepSeek.py => Test/T7_CallDeepSeek.py} (100%) delete mode 100644 dsRag/__pycache__/T2_Txt2Vec.cpython-310.pyc diff --git a/dsRag/T4_ManageMapping.py b/dsRag/T1_ManageMapping.py similarity index 100% rename from dsRag/T4_ManageMapping.py rename to dsRag/T1_ManageMapping.py diff --git a/dsRag/T6_Train.py b/dsRag/T2_ImportTxt.py similarity index 100% rename from dsRag/T6_Train.py rename to dsRag/T2_ImportTxt.py diff --git a/dsRag/T9_RAG.py b/dsRag/T3_DeepSeekRag.py similarity index 100% rename from dsRag/T9_RAG.py rename to dsRag/T3_DeepSeekRag.py diff --git a/dsRag/T1_HelloWord.py b/dsRag/Test/T1_HelloWord.py similarity index 100% rename from dsRag/T1_HelloWord.py rename to dsRag/Test/T1_HelloWord.py diff --git a/dsRag/T2_Txt2Vec.py b/dsRag/Test/T2_Txt2Vec.py similarity index 100% rename from dsRag/T2_Txt2Vec.py rename to dsRag/Test/T2_Txt2Vec.py diff --git a/dsRag/T3_LinkEs.py b/dsRag/Test/T3_LinkEs.py similarity index 91% rename from dsRag/T3_LinkEs.py rename to dsRag/Test/T3_LinkEs.py index 9bcef1cd..4dfc8e9e 100644 --- a/dsRag/T3_LinkEs.py +++ b/dsRag/Test/T3_LinkEs.py @@ -10,6 +10,7 @@ es = Elasticsearch( ssl_show_warn=ES_CONFIG["ssl_show_warn"] ) + try: # 获取并格式化索引信息 indices = es.cat.indices(format="json", h="index,health,status,pri,rep,docs.count,store.size") @@ -22,4 +23,5 @@ try: print(f"{idx['index']}\t{idx['health']}\t{idx['status']}\t{idx['pri']}\t{idx['rep']}\t{idx['docs.count']}\t{idx['store.size']}") except Exception as e: - print(f"获取索引时出错: {str(e)}") \ No newline at end of file + print(f"获取索引时出错: {str(e)}") + diff --git a/dsRag/Test/T4_TestIKSmart.py b/dsRag/Test/T4_TestIKSmart.py new file mode 100644 index 00000000..a4a07459 --- /dev/null +++ b/dsRag/Test/T4_TestIKSmart.py @@ -0,0 +1,20 @@ +from Config.Config import ES_CONFIG +from elasticsearch import Elasticsearch +import warnings + +# 初始化ES连接 +es = Elasticsearch( + hosts=ES_CONFIG["hosts"], + basic_auth=ES_CONFIG["basic_auth"], + verify_certs=ES_CONFIG["verify_certs"], + ssl_show_warn=ES_CONFIG["ssl_show_warn"] +) + + +# 在T3_LinkEs.py中添加测试 +res = es.indices.analyze( + index="knowledge_base", + body={"text": "云南省初中在校生情况", "analyzer": "ik_smart"} +) +print(res) +# 预期输出:['云南省', '初中', '在校生', '情况'] diff --git a/dsRag/T5_SentenceSave.py b/dsRag/Test/T5_SentenceSave.py similarity index 93% rename from dsRag/T5_SentenceSave.py rename to dsRag/Test/T5_SentenceSave.py index 8363d826..f2ec3c64 100644 --- a/dsRag/T5_SentenceSave.py +++ b/dsRag/Test/T5_SentenceSave.py @@ -7,13 +7,13 @@ logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', handlers=[ - logging.FileHandler('sentence_save.log'), + logging.FileHandler('../sentence_save.log'), logging.StreamHandler() ] ) from Config.Config import ES_CONFIG -from T2_Txt2Vec import text_to_embedding +from Test.T2_Txt2Vec import text_to_embedding # 初始化ES连接 es = Elasticsearch( diff --git a/dsRag/T7_Query.py b/dsRag/Test/T6_Query.py similarity index 93% rename from dsRag/T7_Query.py rename to dsRag/Test/T6_Query.py index f2521eca..30a5192f 100644 --- a/dsRag/T7_Query.py +++ b/dsRag/Test/T6_Query.py @@ -65,4 +65,4 @@ def test_queries(file_path): print("="*50) if __name__ == "__main__": - test_queries("人口变化趋势对云南教育的影响.txt") \ No newline at end of file + test_queries("../人口变化趋势对云南教育的影响.txt") \ No newline at end of file diff --git a/dsRag/T8_CallDeepSeek.py b/dsRag/Test/T7_CallDeepSeek.py similarity index 100% rename from dsRag/T8_CallDeepSeek.py rename to dsRag/Test/T7_CallDeepSeek.py diff --git a/dsRag/__pycache__/T2_Txt2Vec.cpython-310.pyc b/dsRag/__pycache__/T2_Txt2Vec.cpython-310.pyc deleted file mode 100644 index d6e0b8bde176ebfd4e069f96f5ecd2cb96506e8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 650 zcmZ8c&ui0g6#sscv`tex-28R$QoTq8J1mGIB1&8Epl-~%vbYhld|zW`nr}?L(ONv& z!$4MM)gjc&>S5qT9SlLI|46QyZasP5MZZ}YsPFN9zt4MoXf~@LF1-tL_gw*@A93-w z$h^45&40=rK`J7c2sW;cqEJO3u1iGhV~mJI5~iRgAW=pONi_*6NVc&mKRgC$P)L%b zh};oZ$JGoRB5BC1XZz>`YI9@_5k*20YK#1eatED9{>8_x)wpNShHC?Zg@1-i7A)$@kkdeU9OARBb}|8?nWPa!&jeo`zukWADrY{qe;B= z`pbXw5PPje!0P8N@nGV-ZM