You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

2 weeks ago
import asyncio
import logging
import os
2 weeks ago
from lightrag import LightRAG
2 weeks ago
from lightrag.kg.shared_storage import initialize_pipeline_status
2 weeks ago
from lightrag.utils import EmbeddingFunc
2 weeks ago
from Config.Config import EMBED_DIM, EMBED_MAX_TOKEN_SIZE, LLM_MODEL_NAME
2 weeks ago
from Util.LightRagUtil import embedding_func, llm_model_func, initialize_pg_rag
2 weeks ago
2 weeks ago
# 在程序开始时添加以下配置
logging.basicConfig(
level=logging.INFO, # 设置日志级别为INFO
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# 或者如果你想更详细地控制日志输出
logger = logging.getLogger('lightrag')
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
logger.addHandler(handler)
2 weeks ago
WORKING_DIR = f"./dickens-pg"
2 weeks ago
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO)
async def main():
2 weeks ago
try:
2 weeks ago
rag = await initialize_pg_rag(WORKING_DIR)
2 weeks ago
with open(f"../Txt/sushi.txt", "r", encoding="utf-8") as f:
await rag.ainsert(f.read())
finally:
if rag:
await rag.finalize_storages()
2 weeks ago
if __name__ == "__main__":
2 weeks ago
asyncio.run(main())