parent
3c655d4ca1
commit
0f184f08a6
@ -1,48 +0,0 @@
|
||||
import asyncio
|
||||
import inspect
|
||||
import logging
|
||||
|
||||
from lightrag import QueryParam
|
||||
|
||||
from Util.LightRagUtil import configure_logging, print_stream, initialize_pg_rag
|
||||
|
||||
# 在程序开始时添加以下配置
|
||||
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)
|
||||
|
||||
WORKING_DIR = f"./dsWorking"
|
||||
|
||||
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO)
|
||||
|
||||
|
||||
async def main():
|
||||
try:
|
||||
rag = await initialize_pg_rag(WORKING_DIR=WORKING_DIR, workspace='SuShi')
|
||||
resp = await rag.aquery(
|
||||
# "苏轼的家人都有谁?",
|
||||
"苏轼与美食",
|
||||
param=QueryParam(mode="hybrid", stream=True),
|
||||
)
|
||||
if inspect.isasyncgen(resp):
|
||||
await print_stream(resp)
|
||||
else:
|
||||
print(resp)
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
finally:
|
||||
if rag:
|
||||
await rag.finalize_storages()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
configure_logging()
|
||||
asyncio.run(main())
|
Loading…
Reference in new issue