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
920 B
36 lines
920 B
2 weeks ago
|
import asyncio
|
||
|
import inspect
|
||
|
from Util.LightRagUtil import configure_logging, initialize_rag, print_stream
|
||
|
from lightrag import QueryParam
|
||
|
|
||
|
# 数学
|
||
2 weeks ago
|
#WORKING_DIR = "./Topic/Math"
|
||
2 weeks ago
|
# 苏轼
|
||
2 weeks ago
|
#WORKING_DIR = "./Topic/Chinese"
|
||
|
|
||
|
# 化学
|
||
|
WORKING_DIR = "./Topic/Chemistry"
|
||
2 weeks ago
|
|
||
|
async def main():
|
||
|
try:
|
||
|
rag = await initialize_rag(WORKING_DIR)
|
||
|
resp = await rag.aquery(
|
||
2 weeks ago
|
"氧化铁与硝酸的化学反应方程式是什么?",
|
||
2 weeks ago
|
#"小学数学有哪些模型",
|
||
2 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())
|