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.

28 lines
729 B

3 weeks ago
import asyncio
import inspect
from Util.LightRagUtil import configure_logging, initialize_rag, print_stream, WORKING_DIR
from lightrag import QueryParam
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())