diff --git a/dsLightRag/Test/T1_WriteToPg.py b/dsLightRag/Test/T1_WriteToPg.py index 120ab1dd..5c633d27 100644 --- a/dsLightRag/Test/T1_WriteToPg.py +++ b/dsLightRag/Test/T1_WriteToPg.py @@ -15,18 +15,30 @@ logger.setLevel(logging.INFO) handler = logging.StreamHandler() handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) logger.addHandler(handler) - -WORKING_DIR = f"./dickens-pg" logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO) +# 使用PG库后,这个是没有用的,但目前的项目代码要求必传,就写一个吧。 +WORKING_DIR = f"./dsWorking" + +#### 下面三个要注意写清楚内容 #### +# 1、工作空间【知识库名称】 +workspace = "dsideal" +# 2、文档名称【不允许出现重复,因为后面需要以此为条件查询】 +docx_name = "sushi.txt" +# 3、文档路径 +docx_path = "../Txt/"+docx_name + + + async def main(): try: - rag = await initialize_pg_rag(WORKING_DIR=WORKING_DIR,workspace='dsideal') - with open(f"../Txt/sushi.txt", "r", encoding="utf-8") as f: - await rag.ainsert(input=f.read(),file_paths=[f"sushi.txt"]) # 添加来源参数 + rag = await initialize_pg_rag(WORKING_DIR=WORKING_DIR, workspace=workspace) + with open(docx_path, "r", encoding="utf-8") as f: + await rag.ainsert(input=f.read(), file_paths=[docx_name]) # 添加来源参数 finally: if rag: await rag.finalize_storages() + if __name__ == "__main__": asyncio.run(main())