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.

36 lines
924 B

import asyncio
import inspect
from Util.LightRagUtil import configure_logging, initialize_rag, print_stream
from lightrag import QueryParam
# 数学
WORKING_DIR = "./Topic/Math"
TXT_FILE = "小学数学教学中的若干问题.txt"
# 苏轼
#WORKING_DIR = "./Topic/Chinese"
#TXT_FILE = "sushi.txt"
async def main():
try:
rag = await initialize_rag(WORKING_DIR)
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())