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 d6e0b8bd..00000000 Binary files a/dsRag/__pycache__/T2_Txt2Vec.cpython-310.pyc and /dev/null differ