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

3 weeks ago
import asyncio
import inspect
3 weeks ago
from Util.LightRagUtil import configure_logging, initialize_rag, print_stream
3 weeks ago
from lightrag import QueryParam
3 weeks ago
# 数学
WORKING_DIR = "./Topic/Math"
TXT_FILE = "小学数学教学中的若干问题.txt"
# 苏轼
#WORKING_DIR = "./Topic/Chinese"
#TXT_FILE = "sushi.txt"
3 weeks ago
async def main():
try:
rag = await initialize_rag(WORKING_DIR)
resp = await rag.aquery(
3 weeks ago
#"苏轼有几个妻子?",
"小学数学有哪些模型",
3 weeks ago
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())